Auto remove outdated turret entities
This commit is contained in:
parent
a310d0338a
commit
347a8807bf
2 changed files with 18 additions and 3 deletions
|
@ -2,6 +2,10 @@ local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
dofile(modpath.."/api.lua")
|
dofile(modpath.."/api.lua")
|
||||||
|
|
||||||
|
minetest.register_entity("shooter:turret_entity", {
|
||||||
|
visual = "sprite",
|
||||||
|
textures = {"blank.png"},
|
||||||
|
on_activate = function(self)
|
||||||
|
self.object:remove()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
@ -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
|
if SHOOTER_ENABLE_CRAFTING == true then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "shooter_turret:turret",
|
output = "shooter_turret:turret",
|
||||||
|
|
Loading…
Reference in a new issue