mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Enhance script property encoding in encodeInstance.lua
- Updated the encodeInstance function to include additional script properties (Disabled, LinkedSource, etc.) for encoding into the .meta.json5 file. - Improved handling of properties by skipping those that are already managed or should be ignored, ensuring only serializable properties are encoded. - Clarified comments to indicate the necessity of encoding the Source property.
This commit is contained in:
parent
439eb3f5f8
commit
c0d089f0aa
1 changed files with 20 additions and 9 deletions
|
|
@ -147,7 +147,7 @@ encodeInstance = function(instance, parentId, _skipPathCheck)
|
||||||
encodeAttributes(instance, properties)
|
encodeAttributes(instance, properties)
|
||||||
|
|
||||||
if SCRIPT_CLASS_NAMES[instance.ClassName] then
|
if SCRIPT_CLASS_NAMES[instance.ClassName] then
|
||||||
-- For scripts, encode the Source property
|
-- For scripts, encode the Source property (required)
|
||||||
local sourceDescriptor = RbxDom.findCanonicalPropertyDescriptor(instance.ClassName, "Source")
|
local sourceDescriptor = RbxDom.findCanonicalPropertyDescriptor(instance.ClassName, "Source")
|
||||||
if sourceDescriptor then
|
if sourceDescriptor then
|
||||||
local encodeSuccess, encodeResult = encodeProperty(instance, "Source", sourceDescriptor)
|
local encodeSuccess, encodeResult = encodeProperty(instance, "Source", sourceDescriptor)
|
||||||
|
|
@ -162,14 +162,25 @@ encodeInstance = function(instance, parentId, _skipPathCheck)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- For Script class specifically, also encode RunContext property
|
-- Also encode other script properties (Disabled, LinkedSource, etc.)
|
||||||
-- This determines the file suffix (.server.luau, .client.luau, .plugin.luau, .legacy.luau)
|
-- These go into the .meta.json5 file
|
||||||
if instance.ClassName == "Script" then
|
local classDescriptor = RbxDom.findClassDescriptor(instance.ClassName)
|
||||||
local runContextDescriptor = RbxDom.findCanonicalPropertyDescriptor("Script", "RunContext")
|
if classDescriptor then
|
||||||
if runContextDescriptor then
|
for propertyName, propertyDescriptor in classDescriptor.properties do
|
||||||
local encodeSuccess, encodeResult = encodeProperty(instance, "RunContext", runContextDescriptor)
|
-- Skip properties we handle separately or should ignore
|
||||||
|
if SKIP_PROPERTIES[propertyName] then
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
if propertyName == "Source" or propertyName == "Attributes" then
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Only encode serializable properties
|
||||||
|
if propertyDescriptor.scriptability == "ReadWrite" or propertyDescriptor.scriptability == "Read" then
|
||||||
|
local encodeSuccess, encodeResult = encodeProperty(instance, propertyName, propertyDescriptor)
|
||||||
if encodeSuccess and encodeResult ~= nil then
|
if encodeSuccess and encodeResult ~= nil then
|
||||||
properties.RunContext = encodeResult
|
properties[propertyName] = encodeResult
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue