From 27edb029caa8366c33629b3fcb86e9728ed2d15a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 2 Aug 2022 15:51:27 +0200 Subject: [PATCH] Fix spawning of infinite rocks --- mods/tutorial/init.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mods/tutorial/init.lua b/mods/tutorial/init.lua index 66705c6..9404095 100644 --- a/mods/tutorial/init.lua +++ b/mods/tutorial/init.lua @@ -1181,9 +1181,13 @@ minetest.register_node("tutorial:itemspawner", { local offset = minetest.string_to_pos(meta:get_string("offset")) local itemstring = meta:get_string("itemstring") - local alias = minetest.registered_aliases[itemstring] + local test_item = ItemStack(itemstring) + local test_itemname = test_item:get_name() + local alias = minetest.registered_aliases[test_itemname] + local itemname if alias then - itemstring = alias + test_item:set_name(alias) + itemstring = test_item:to_string() end local x, y, z = offset.x, offset.y, offset.z local spawnpos = {x=pos.x+x, y=pos.y+y, z=pos.z+z} @@ -1191,7 +1195,9 @@ minetest.register_node("tutorial:itemspawner", { for o=1, #objs do local ent = objs[o]:get_luaentity() if ent then - if ent.name == "__builtin:item" and ent.itemstring == itemstring then + local ent_itemstack = ItemStack(ent.itemstring) + local itemstack = ItemStack(itemstring) + if ent.name == "__builtin:item" and ent_itemstack:get_name() == itemstack:get_name() then -- Remove node when item was spawned successfully. -- So it doesn't get in the way. minetest.remove_node(pos)