Printing out the indices for the pairs loop in findName() reveals that the loop is stuck for no reason:
Code: Select all
local reported = false
function Game:findName(askedname)
local result = {}
local looped = {}
for i, v in pairs(self.gameloop) do
looped[#looped+1] = i
for j, name in ipairs(v.classes) do
if name == askedname then
if result[1000] and not reported then
reported = true
local objCount = 0
for _ in pairs(self.gameloop) do -- This loop does not get stuck, even though it's exactly the same as the outermost loop!
objCount = objCount + 1
end
print("objCount="..objCount, "#classes="..#v.classes, "i="..i, "j="..j, "name="..name)
print("looped", table.concat(looped, ","))
end
insert(result, v)
end
end
end
return result
end
-- Example output:
--
-- objCount=45 #classes=4 i=1046 j=4 name=Player
-- looped 1379,1026,1034,1036,1042,1046,1048,1379,1026,1034,1036,1042,1046,1048,1379,1026...
--
Notice how 'looped' contains a repeating pattern (1379...1048,1379). All the numbers are different every run, including how many values are in the repeating pattern. LuaJIT is definitively doing something weird in that particular place.