Skip to content

Commit

Permalink
Fail gracefully in rbx_dom_lua when properties are BinaryStrings
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethloeffler committed Nov 1, 2024
1 parent c5207ff commit 1ccab17
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rbx_dom_lua/src/customProperties.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
local CollectionService = game:GetService("CollectionService")
local ScriptEditorService = game:GetService("ScriptEditorService")

local Error = require(script.Parent.Error)

--- A list of `Enum.Material` values that are used for Terrain.MaterialColors
local TERRAIN_MATERIAL_COLORS = {
Enum.Material.Grass,
Expand Down Expand Up @@ -51,6 +53,10 @@ return {
return true, instance:GetAttributes()
end,
write = function(instance, _, value)
if typeof(value) ~= "table" then
return false, Error.new(Error.Kind.CannotParseBinaryString)
end

local existing = instance:GetAttributes()
local didAllWritesSucceed = true

Expand Down Expand Up @@ -160,9 +166,14 @@ return {
return true, colors
end,
write = function(instance: Terrain, _, value: { [Enum.Material]: Color3 })
if typeof(value) ~= "table" then
return false, Error.new(Error.Kind.CannotParseBinaryString)
end

for material, color in value do
instance:SetMaterialColor(material, color)
end

return true
end,
},
Expand Down

0 comments on commit 1ccab17

Please sign in to comment.