init.lua 794 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. local v = {x=0,y=0,z=0}
  2. local function setvec(vec, x, y, z)
  3. vec.x = x
  4. vec.y = y
  5. vec.z = z
  6. return vec
  7. end
  8. local time = 0
  9. local tex = "unknown_object.png"
  10. minetest.register_entity(":entity:test", {
  11. initial_properties = {
  12. visual = "mesh",
  13. mesh = "propeller.obj",
  14. textures = {tex, tex, tex, tex, tex, tex},
  15. automatic_rotate = 20,
  16. },
  17. on_punch = function(self)
  18. self.object:remove()
  19. end,
  20. on_step = function(self, dtime)
  21. time = time + dtime
  22. if time >= 3 then
  23. time = 0
  24. self.object:set_rotation(setvec(v,2*math.pi*math.random(),0,0))
  25. end
  26. end,
  27. })
  28. minetest.register_chatcommand("entitytest", {
  29. func = function(name)
  30. local pos = minetest.get_player_by_name(name):get_pos()
  31. pos.x = pos.x + 2
  32. pos.y = pos.y + 1
  33. minetest.add_entity(pos, "entity:test")
  34. end,
  35. })