Fix broken item spawners
Also ignore their "spawned" property
This commit is contained in:
parent
11047b58ea
commit
e6c6f2f0d0
@ -1139,7 +1139,6 @@ minetest.register_node("tutorial:itemspawner", {
|
|||||||
groups = {creative_breakable=1},
|
groups = {creative_breakable=1},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_int("spawned", 0)
|
|
||||||
meta:set_int("configged", 0)
|
meta:set_int("configged", 0)
|
||||||
local formspec = ""..
|
local formspec = ""..
|
||||||
"size[12,6]"..
|
"size[12,6]"..
|
||||||
@ -1165,7 +1164,7 @@ minetest.register_node("tutorial:itemspawner", {
|
|||||||
end,
|
end,
|
||||||
on_timer = function(pos, elapsed)
|
on_timer = function(pos, elapsed)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if meta:get_int("configged") == 0 then
|
if meta:get_int("configged") == 0 or edit_item_spawners then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1174,36 +1173,23 @@ minetest.register_node("tutorial:itemspawner", {
|
|||||||
local x, y, z = offset.x, offset.y, offset.z
|
local x, y, z = offset.x, offset.y, offset.z
|
||||||
local spawnpos = {x=pos.x+x, y=pos.y+y, z=pos.z+z}
|
local spawnpos = {x=pos.x+x, y=pos.y+y, z=pos.z+z}
|
||||||
local objs = minetest.get_objects_inside_radius(spawnpos, 1)
|
local objs = minetest.get_objects_inside_radius(spawnpos, 1)
|
||||||
local spawned = meta:get_int("spawned")
|
|
||||||
if spawned ~= 1 then
|
|
||||||
for o=1, #objs do
|
for o=1, #objs do
|
||||||
local ent = objs[o]:get_luaentity()
|
local ent = objs[o]:get_luaentity()
|
||||||
if ent then
|
if ent then
|
||||||
if ent.name == "__builtin:item" and ent.itemstring == itemstring then
|
if ent.name == "__builtin:item" and ent.itemstring == itemstring then
|
||||||
if not edit_item_spawners then
|
|
||||||
-- Remove node when item was spawned successfully.
|
-- Remove node when item was spawned successfully.
|
||||||
-- So it doesn't get in the way.
|
-- So it doesn't get in the way.
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return
|
return
|
||||||
else
|
|
||||||
-- Keep node in editing mode
|
|
||||||
meta:set_int("spawned", 1)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
else
|
|
||||||
return
|
|
||||||
end
|
|
||||||
spawned = meta:get_int("spawned")
|
|
||||||
if spawned ~= 1 then
|
|
||||||
if itemstring ~= nil and itemstring ~= "" then
|
if itemstring ~= nil and itemstring ~= "" then
|
||||||
minetest.add_item(spawnpos, itemstring)
|
minetest.add_item(spawnpos, itemstring)
|
||||||
local timer = minetest.get_node_timer(pos)
|
local timer = minetest.get_node_timer(pos)
|
||||||
timer:start(1)
|
timer:start(1)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local timer = minetest.get_node_timer(pos)
|
local timer = minetest.get_node_timer(pos)
|
||||||
timer:start(1)
|
timer:start(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user