Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
function elementAjoute()
local dagger_id
hudPrint(beacon_furnace_2.id)
dagger_id = trouveUneDague(beacon_furnace_2.surface)
local e = findEntity(dagger_id)
if e ~= nil then
hudPrint(e.name)
local s = spawn("ethereal_blade", party.level, beacon_furnace_2.x, beacon_furnace_2.y, beacon_furnace_2.facing, beacon_furnace_2.elevation)
--beacon_furnace_2.surface:addItem(s.item) -- That line is causing me trouble
e:destroyDelayed()
end
end
function trouveUneDague(surface)
for v,i in surface:contents() do
hudPrint(i.go.id)
if i.go.name == "dagger" then return i.go.id end
end
return "nil"
end
Why do I get a stack overflow at the line "beacon_furnace_2.surface:addItem(s.item)" ?
You get a stack overflow because you have a connector from the surface to elementAjoute(). So when you add an item to the surface inside elementAjoute(), it causes a recursive call to elementAjoute(), which adds another item to the surface, which causes another recursive call to elementAjoute(), which adds another item to the surface...