Skip to content

Named ordered dynamic properties lose their order in the editor property sheet #1438

@TiberiumFusion

Description

@TiberiumFusion

When a part defines an ordered list of dynamic properties, if any of those properties have a key that collides with pac's list of known pac properties (like Name, Hide, Size, Scale, Stretch, etc), that property loses its intended ordering in the property sheet.

For example, if a part's GetDynamicProperties() returns a table like so:

{
  [1] = { key = "Shrink", ..., udata = { group = "extras", ... } },
  [2] = { key = "Stretch", ..., udata = { group = "extras", ... } },
}

...then one would expect the "extras" group in the property sheet to display item Shrink first, then item Stretch.
Instead, what happens is that Stretch appears first, then Shrink.

This is due to the following code:

function PART:GetProperties()
<snip>
for _, variables in pairs(pac.VariableOrder) do
for _, key in ipairs(variables) do
for _, prop in ipairs(out) do
if key == prop.key then
if not done[key] then
table_insert(sorted, prop)
done[key] = true
break
end
end
end
end
end

...which forcibly re-sorts all properties (including dynamic properties in dynamic groups) by moving all properties that bear a known built-in pac property name to the top of the list. So, since Stretch is a built-in pac property on the trail part, the dynamic property with key Stretch gets moved to the top of the list. It happens on every single part too, e.g. if the faceposer part's GetDynamicProperties() returns the example table from above, that tables' ordering still gets clobbered and Stretch still gets moved to the top of the list, because PART:GetProperties() is applying sorting on built-in pac properties names for every single pac part to every single part, not just e.g. the faceposer part's known built-in names to the faceposer part. Regardless of whatever the original intent of this sorting was, its implemented is deeply flawed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions