1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Reshape LuaEntityCAO implementation a bit and make TNT to blink

This commit is contained in:
Perttu Ahola 2011-11-26 12:35:30 +02:00
parent 1ce749c86a
commit 70363847aa
6 changed files with 373 additions and 307 deletions

View file

@ -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