From 61108c179a321885be295de6596fd00fd0b0c91b Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Sun, 10 Jan 2021 19:41:47 +0100 Subject: [PATCH] entity cleanups --- cannon.lua | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/cannon.lua b/cannon.lua index 8817157..45b07ce 100644 --- a/cannon.lua +++ b/cannon.lua @@ -9,15 +9,30 @@ local register_spacecannon = function(def) initial_properties = { visual = "cube", visual_size = {x=0.25, y=0.25}, - textures = {entity_texture,entity_texture,entity_texture,entity_texture,entity_texture,entity_texture}, + textures = { + entity_texture, + entity_texture, + entity_texture, + entity_texture, + entity_texture, + entity_texture + }, collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25}, physical = false }, timer = 0, + lifetime = 0, static_save = false, on_step = function(self, dtime) self.timer = self.timer + dtime + self.lifetime = self.lifetime + dtime + + if self.lifetime > def.timeout then + self.object:remove() + return + end + local pos = self.object:getpos() if self.timer > 0.5 then @@ -70,16 +85,7 @@ local register_spacecannon = function(def) self.object:remove() end - end, - - on_activate = function(self) - minetest.after(def.timeout, - function(me) - me.object:remove() - end, - self) end - })