Lua:
function getTileThingByPos(position)
local t = Tile(position)
if t == nil then
if position.stackpos == -1 then
return -1
end
return pushThing(nil)
end
if position.stackpos == -1 then
return t:getThingCount()
end
return pushThing(t:getThing(position.stackpos))
end
Using this "possible infinite loop catcher" script from [ANY TFS] Catch scripts that freeze server (https://otland.net/threads/any-tfs-catch-scripts-that-freeze-server.261466/)
I have set the limit to 1,000,000 loops to reduce false positives. This script shows up as a possible infinite loop, specifically here
if t == nil then
I was looking at this code, and realized immediately how this could be easily broken. If this is used in a script, and the tile returns nil (very possible if wrong coordinate), then it will lead to an infinite loop. The reason why I posted this into support is... I'm not sure how this could be avoided.
Any ideas?