Basic reification, works for model-like projects but not place-like ones

This commit is contained in:
Lucien Greathouse
2018-12-17 17:52:00 -08:00
parent 05594ecca0
commit d807d22350

View File

@@ -4,6 +4,27 @@ local Logging = require(script.Parent.Logging)
local REMOTE_URL = ("http://localhost:%d"):format(Config.port)
local function reify(instanceData, id, parent)
local data = instanceData[id]
local instance = Instance.new(data.ClassName)
for key, value in pairs(data.Properties) do
-- TODO: Branch on value.Type
instance[key] = value.Value
end
instance.Name = data.Name
for _, childId in ipairs(data.Children) do
reify(instanceData, childId, instance)
end
instance.Parent = parent
return instance
end
local Session = {}
Session.__index = Session
@@ -25,7 +46,8 @@ function Session.new()
:andThen(function()
return api:read({api.rootInstanceId})
end)
:andThen(function()
:andThen(function(response)
reify(response.instances, api.rootInstanceId, game.ReplicatedStorage)
return api:retrieveMessages()
end)
:catch(function(message)