forked from rojo-rbx/rojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatePatchSet.lua
More file actions
41 lines (32 loc) · 1.15 KB
/
createPatchSet.lua
File metadata and controls
41 lines (32 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--[[
Take an InstanceMap and a dictionary mapping instances to sets of property
names. Populate a patch with the encoded values of all the given properties
on all the given instances (or, if any changes set Parent to nil, removals
of instances) and return the patch.
]]
local Packages = script.Parent.Parent.Parent.Packages
local Log = require(Packages.Log)
local PatchSet = require(script.Parent.Parent.PatchSet)
local encodePatchUpdate = require(script.Parent.encodePatchUpdate)
return function(instanceMap, propertyChanges)
local patch = PatchSet.newEmpty()
for instance, properties in propertyChanges do
local instanceId = instanceMap.fromInstances[instance]
if instanceId == nil then
Log.warn("Ignoring change for instance {:?} as it is unknown to Rojo", instance)
continue
end
if properties.Parent then
if instance.Parent == nil then
table.insert(patch.removed, instanceId)
else
Log.warn("Cannot sync non-nil Parent property changes yet")
end
else
local update = encodePatchUpdate(instance, instanceId, properties)
table.insert(patch.updated, update)
end
propertyChanges[instance] = nil
end
return patch
end