aboutsummaryrefslogtreecommitdiff
path: root/games/devtest/mods/testentities/armor.lua
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-07-18 13:53:15 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-07-18 13:53:15 +0200
commitffe3c2ae0db6fed0f2b08b71bfa69f3d3df3bb1f (patch)
treecc7d9f74a43215c5d8e3965a2bfc2aea5867a7a0 /games/devtest/mods/testentities/armor.lua
parent45aa2516b2fc675df7049bc9ed713600c95b6423 (diff)
parent82731d0d3d8bfe9e56f89466991f13c037f3a61e (diff)
downloaddragonfireclient-ffe3c2ae0db6fed0f2b08b71bfa69f3d3df3bb1f.tar.xz
Update to minetest 5.4.0-dev
Diffstat (limited to 'games/devtest/mods/testentities/armor.lua')
-rw-r--r--games/devtest/mods/testentities/armor.lua41
1 files changed, 41 insertions, 0 deletions
diff --git a/games/devtest/mods/testentities/armor.lua b/games/devtest/mods/testentities/armor.lua
new file mode 100644
index 000000000..4c30cec8d
--- /dev/null
+++ b/games/devtest/mods/testentities/armor.lua
@@ -0,0 +1,41 @@
+-- Armorball: Test entity for testing armor groups
+-- Rightclick to change armor group
+
+local phasearmor = {
+ [0]={icy=100},
+ [1]={firy=100},
+ [2]={fleshy=100},
+ [3]={immortal=1},
+ [4]={punch_operable=1},
+}
+
+minetest.register_entity("testentities:armorball", {
+ initial_properties = {
+ hp_max = 20,
+ physical = false,
+ collisionbox = {-0.4,-0.4,-0.4, 0.4,0.4,0.4},
+ visual = "sprite",
+ visual_size = {x=1, y=1},
+ textures = {"testentities_armorball.png"},
+ spritediv = {x=1, y=5},
+ initial_sprite_basepos = {x=0, y=0},
+ },
+
+ _phase = 2,
+
+ on_activate = function(self, staticdata)
+ minetest.log("action", "[testentities] armorball.on_activate")
+ self.object:set_armor_groups(phasearmor[self._phase])
+ self.object:set_sprite({x=0, y=self._phase})
+ end,
+
+ on_rightclick = function(self, clicker)
+ -- Change armor group and sprite
+ self._phase = self._phase + 1
+ if self._phase >= 5 then
+ self._phase = 0
+ end
+ self.object:set_sprite({x=0, y=self._phase})
+ self.object:set_armor_groups(phasearmor[self._phase])
+ end,
+})