From 347a8807bf1f60d024ebc075b9d818d16e9a17ad Mon Sep 17 00:00:00 2001 From: stujones11 Date: Wed, 3 Jan 2018 20:24:36 +0000 Subject: [PATCH] Auto remove outdated turret entities --- shooter/init.lua | 10 +++++++--- shooter_turret/init.lua | 11 +++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/shooter/init.lua b/shooter/init.lua index d1616d0..894b12f 100644 --- a/shooter/init.lua +++ b/shooter/init.lua @@ -2,6 +2,10 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath.."/api.lua") - - - +minetest.register_entity("shooter:turret_entity", { + visual = "sprite", + textures = {"blank.png"}, + on_activate = function(self) + self.object:remove() + end, +}) diff --git a/shooter_turret/init.lua b/shooter_turret/init.lua index 67aef8d..9d7335e 100644 --- a/shooter_turret/init.lua +++ b/shooter_turret/init.lua @@ -253,6 +253,17 @@ minetest.register_node("shooter_turret:turret", { }, }) +minetest.register_abm({ + nodenames = {"shooter_turret:turret"}, + interval = 15, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + if not get_turret_entity(pos) then + minetest.add_entity(pos, "shooter_turret:turret_entity") + end + end +}) + if SHOOTER_ENABLE_CRAFTING == true then minetest.register_craft({ output = "shooter_turret:turret",