2
0

particles.lua 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. minetest.register_tool("testtools:particle_spawner", {
  2. description = "Particle Spawner".."\n"..
  3. "Punch: Spawn random test particle",
  4. inventory_image = "testtools_particle_spawner.png",
  5. groups = { testtool = 1, disable_repair = 1 },
  6. on_use = function(itemstack, user, pointed_thing)
  7. local pos = minetest.get_pointed_thing_position(pointed_thing, true)
  8. if pos == nil then
  9. if user then
  10. pos = user:get_pos()
  11. end
  12. end
  13. pos = vector.add(pos, {x=0, y=0.5, z=0})
  14. local tex, anim
  15. if math.random(0, 1) == 0 then
  16. tex = "testtools_particle_sheet.png"
  17. anim = {type="sheet_2d", frames_w=3, frames_h=2, frame_length=0.5}
  18. else
  19. tex = "testtools_particle_vertical.png"
  20. anim = {type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3}
  21. end
  22. minetest.add_particle({
  23. pos = pos,
  24. velocity = {x=0, y=0, z=0},
  25. acceleration = {x=0, y=0.04, z=0},
  26. expirationtime = 6,
  27. collisiondetection = true,
  28. texture = tex,
  29. animation = anim,
  30. size = 4,
  31. glow = math.random(0, 5),
  32. })
  33. end,
  34. })