diff --git a/plugin/src/Session.lua b/plugin/src/Session.lua index b01c30d7..3414bc24 100644 --- a/plugin/src/Session.lua +++ b/plugin/src/Session.lua @@ -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)