diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-11-26 12:35:30 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-11-29 19:13:53 +0200 |
commit | 70363847aacbf765c60a294940ba50c8bb256cc6 (patch) | |
tree | b1f5c1e5c519f578b858be98b98a522020d6515d /data/mods | |
parent | 1ce749c86a2af539549ecefab5d3de0fde8aeedf (diff) | |
download | minetest-70363847aacbf765c60a294940ba50c8bb256cc6.tar.gz minetest-70363847aacbf765c60a294940ba50c8bb256cc6.tar.bz2 minetest-70363847aacbf765c60a294940ba50c8bb256cc6.zip |
Reshape LuaEntityCAO implementation a bit and make TNT to blink
Diffstat (limited to 'data/mods')
-rw-r--r-- | data/mods/default/init.lua | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/data/mods/default/init.lua b/data/mods/default/init.lua index 8f8188df5..b9af94be6 100644 --- a/data/mods/default/init.lua +++ b/data/mods/default/init.lua @@ -1176,18 +1176,32 @@ local TNT = { timer = 0, -- Number of punches required to defuse health = 1, + blinktimer = 0, + blinkstatus = true, } -- Called when a TNT object is created function TNT:on_activate(staticdata) print("TNT:on_activate()") - self.object:setvelocity({x=0, y=2, z=0}) + self.object:setvelocity({x=0, y=4, z=0}) self.object:setacceleration({x=0, y=-10, z=0}) + self.object:settexturemod("^[brighten") end -- Called periodically function TNT:on_step(dtime) --print("TNT:on_step()") + self.timer = self.timer + dtime + self.blinktimer = self.blinktimer + dtime + if self.blinktimer > 0.5 then + self.blinktimer = self.blinktimer - 0.5 + if blinkstatus then + self.object:settexturemod("") + else + self.object:settexturemod("^[brighten") + end + blinkstatus = not blinkstatus + end end -- Called when object is punched |