mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 05:06:29 +00:00
47 lines
1.1 KiB
Lua
47 lines
1.1 KiB
Lua
local CollectionService = game:GetService("CollectionService")
|
|
|
|
-- Defines how to read and write properties that aren't directly scriptable.
|
|
--
|
|
-- The reflection database refers to these as having scriptability = "Custom"
|
|
return {
|
|
Instance = {
|
|
Tags = {
|
|
read = function(instance, key)
|
|
local tagList = CollectionService:GetTags(instance)
|
|
|
|
return true, table.concat(tagList, "\0")
|
|
end,
|
|
write = function(instance, key, value)
|
|
local existingTags = CollectionService:GetTags(instance)
|
|
|
|
local unseenTags = {}
|
|
for _, tag in ipairs(existingTags) do
|
|
unseenTags[tag] = true
|
|
end
|
|
|
|
local tagList = string.split(value, "\0")
|
|
for _, tag in ipairs(tagList) do
|
|
unseenTags[tag] = nil
|
|
CollectionService:AddTag(instance, tag)
|
|
end
|
|
|
|
for tag in pairs(unseenTags) do
|
|
CollectionService:RemoveTag(instance, tag)
|
|
end
|
|
|
|
return true
|
|
end,
|
|
},
|
|
},
|
|
LocalizationTable = {
|
|
Contents = {
|
|
read = function(instance, key)
|
|
return true, instance:GetContents()
|
|
end,
|
|
write = function(instance, key, value)
|
|
instance:SetContents(value)
|
|
return true
|
|
end,
|
|
},
|
|
},
|
|
} |