Deletion, wrangling parents a little bit

This commit is contained in:
Lucien Greathouse 2018-05-26 02:28:34 -07:00
parent 8729de1312
commit e4f35b29bd
4 changed files with 60 additions and 10 deletions

View file

@ -21,7 +21,9 @@ function Session.new()
return api:readAll()
:andThen(function(instances)
local visited = {}
for id, instance in pairs(instances) do
visited[id] = true
if id ~= "0" then
local existing = created[id]
if existing ~= nil then
@ -45,6 +47,12 @@ function Session.new()
created[id].Parent = created[tostring(instance.parent)]
end
end
for id, object in pairs(created) do
if not visited[id] then
object:Destroy()
end
end
end)
end