mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 23:26:19 +00:00
Basic reification, works for model-like projects but not place-like ones
This commit is contained in:
@@ -4,6 +4,27 @@ local Logging = require(script.Parent.Logging)
|
|||||||
|
|
||||||
local REMOTE_URL = ("http://localhost:%d"):format(Config.port)
|
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 = {}
|
local Session = {}
|
||||||
Session.__index = Session
|
Session.__index = Session
|
||||||
|
|
||||||
@@ -25,7 +46,8 @@ function Session.new()
|
|||||||
:andThen(function()
|
:andThen(function()
|
||||||
return api:read({api.rootInstanceId})
|
return api:read({api.rootInstanceId})
|
||||||
end)
|
end)
|
||||||
:andThen(function()
|
:andThen(function(response)
|
||||||
|
reify(response.instances, api.rootInstanceId, game.ReplicatedStorage)
|
||||||
return api:retrieveMessages()
|
return api:retrieveMessages()
|
||||||
end)
|
end)
|
||||||
:catch(function(message)
|
:catch(function(message)
|
||||||
|
|||||||
Reference in New Issue
Block a user