Lua subtility ?...
Posted: Mon Jul 18, 2016 11:33 am
Hi,
can someone explain me why this is not working :
if I use table.insert(tab, {entity=ent,m=1, n=2 }), then I can travel through this table and find back the entity, but it is not really indexed...
can someone explain me why this is not working :
Code: Select all
tab= {}
for _, ent in pairs(surface.find_entities_filtered{area=a, type="assembling-machine"}) do
tab[ent] = {m=1, n=2 } -- i create a table indexed by entities
end
for _, ent in pairs(surface.find_entities_filtered{area=a, type="assembling-machine"}) do -- then I try to access this table I created before
local ref = tab[ent]
-- here, ref contains nil : it does not point to the object I created in the previous loop!
end