mirror of
https://github.com/sr229/metastruct-experiments.git
synced 2024-09-20 06:30:36 +00:00
run mark and sweep on a think hook
This commit is contained in:
parent
97fa187f65
commit
bf6fe6ef91
1 changed files with 5 additions and 5 deletions
|
@ -48,7 +48,6 @@ end
|
|||
function cleanupInvalid(t, v)
|
||||
for i, sv in ipairs(t) do
|
||||
if not isValid(sv.this) then
|
||||
print("WARNING: " .. tostring(sv.this) .. " is no longer valid but exists in table.")
|
||||
table.remove(t, i)
|
||||
end
|
||||
end
|
||||
|
@ -101,15 +100,16 @@ if CLIENT then
|
|||
end
|
||||
end)
|
||||
|
||||
timer.create("cleanup_invalid", 0.8, 0, function()
|
||||
cleanupInvalid(serverMetadata.runningChips)
|
||||
end)
|
||||
|
||||
-- update the running chip entries when necessary
|
||||
timer.create("update_data", 5, 0, function()
|
||||
getRunningChips()
|
||||
end)
|
||||
|
||||
-- mark and sweep invalid entries
|
||||
hook.add("think", "dispose_object", function()
|
||||
cleanupInvalid(serverMetadata.runningChips)
|
||||
end)
|
||||
|
||||
hook.add("render", "metadataRenderMain", function()
|
||||
render.setColor(Color(255, 34, 34))
|
||||
render.drawText(10, 10, "Server Name: " .. serverMetadata.serverName)
|
||||
|
|
Loading…
Reference in a new issue