Skip to content

Commit

Permalink
Update rbx-dom dependencies (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethloeffler authored Aug 22, 2024
1 parent 5e1cab2 commit 7309707
Show file tree
Hide file tree
Showing 4 changed files with 11,509 additions and 1,277 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ memofs = { version = "0.3.0", path = "crates/memofs" }
# rbx_reflection_database = { path = "../rbx-dom/rbx_reflection_database" }
# rbx_xml = { path = "../rbx-dom/rbx_xml" }

rbx_binary = "0.7.4"
rbx_dom_weak = "2.7.0"
rbx_reflection = "4.5.0"
rbx_reflection_database = "0.2.10"
rbx_xml = "0.13.3"
rbx_binary = "0.7.7"
rbx_dom_weak = "2.9.0"
rbx_reflection = "4.7.0"
rbx_reflection_database = "0.2.12"
rbx_xml = "0.13.5"

anyhow = "1.0.80"
backtrace = "0.3.69"
Expand Down
59 changes: 41 additions & 18 deletions plugin/rbx_dom_lua/customProperties.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ local TERRAIN_MATERIAL_COLORS = {
Enum.Material.Pavement,
}

local function isAttributeNameValid(attributeName)
-- For SetAttribute to succeed, the attribute name must be less than or
-- equal to 100 characters...
return #attributeName <= 100
-- ...and must only contain alphanumeric characters, periods, hyphens,
-- underscores, or forward slashes.
and attributeName:match("[^%w%.%-_/]") == nil
end

local function isAttributeNameReserved(attributeName)
-- For SetAttribute to succeed, attribute names must not use the RBX
-- prefix, which is reserved by Roblox.
return attributeName:sub(1, 3) == "RBX"
end

-- Defines how to read and write properties that aren't directly scriptable.
--
-- The reflection database refers to these as having scriptability = "Custom"
Expand All @@ -40,26 +55,33 @@ return {
local didAllWritesSucceed = true

for attributeName, attributeValue in pairs(value) do
local isNameValid =
-- For our SetAttribute to succeed, the attribute name must be
-- less than or equal to 100 characters...
#attributeName <= 100
-- ...must only contain alphanumeric characters, periods, hyphens,
-- underscores, or forward slashes...
and attributeName:match("[^%w%.%-_/]") == nil
-- ... and must not use the RBX prefix, which is reserved by Roblox.
and attributeName:sub(1, 3) ~= "RBX"

if isNameValid then
instance:SetAttribute(attributeName, attributeValue)
else
if isAttributeNameReserved(attributeName) then
-- If the attribute name is reserved, then we don't
-- really care about reporting any failures about
-- it.
continue
end

if not isAttributeNameValid(attributeName) then
didAllWritesSucceed = false
continue
end

instance:SetAttribute(attributeName, attributeValue)
end

for key in pairs(existing) do
if value[key] == nil then
instance:SetAttribute(key, nil)
for existingAttributeName in pairs(existing) do
if isAttributeNameReserved(existingAttributeName) then
continue
end

if not isAttributeNameValid(existingAttributeName) then
didAllWritesSucceed = false
continue
end

if value[existingAttributeName] == nil then
instance:SetAttribute(existingAttributeName, nil)
end
end

Expand Down Expand Up @@ -113,13 +135,14 @@ return {
},
WorldPivotData = {
read = function(instance)
return true, instance:GetPivot()
return true, instance.WorldPivot
end,
write = function(instance, _, value)
if value == nil then
return true, nil
else
return true, instance:PivotTo(value)
instance.WorldPivot = value
return true
end
end,
},
Expand Down
Loading

0 comments on commit 7309707

Please sign in to comment.