Okay so I figured that if I put a bunch of gameobjects into a table, and then deleted the gameobject, the GC would make the object nil. That doesn’t appear to to be the case becuase I’m actually storing the ID I guess.
So I did some more googling and apparently there is no go.exists() but I found this code snippet.
local function does_object_exist(id)
return pcall(function(id) go.get_position(id) end, id) == true
end
And I tried incoporating that into my code that remakes my enemy list on an enemy death, which is this
local function remove_nils(self)
local new = {}
for k, v in pairs(self.enemies) do
if does_object_exist(v) then
table.insert(new, v)
end
end
self.enemies = new
end
But I’m still getting the error. Help?