armor.lua 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. -- Armorball: Test entity for testing armor groups
  2. -- Rightclick to change armor group
  3. local phasearmor = {
  4. [0]={icy=100},
  5. [1]={fiery=100},
  6. [2]={fleshy=100},
  7. [3]={immortal=1},
  8. [4]={punch_operable=1},
  9. }
  10. minetest.register_entity("testentities:armorball", {
  11. initial_properties = {
  12. hp_max = 20,
  13. physical = false,
  14. collisionbox = {-0.4,-0.4,-0.4, 0.4,0.4,0.4},
  15. visual = "sprite",
  16. visual_size = {x=1, y=1},
  17. textures = {"testentities_armorball.png"},
  18. spritediv = {x=1, y=5},
  19. initial_sprite_basepos = {x=0, y=0},
  20. },
  21. _phase = 2,
  22. on_activate = function(self, staticdata)
  23. minetest.log("action", "[testentities] armorball.on_activate")
  24. self.object:set_armor_groups(phasearmor[self._phase])
  25. self.object:set_sprite({x=0, y=self._phase})
  26. end,
  27. on_rightclick = function(self, clicker)
  28. -- Change armor group and sprite
  29. self._phase = self._phase + 1
  30. if self._phase >= 5 then
  31. self._phase = 0
  32. end
  33. self.object:set_sprite({x=0, y=self._phase})
  34. self.object:set_armor_groups(phasearmor[self._phase])
  35. end,
  36. })