GameObject reference fields on Script Components (#85) #97

Merged
crowmaki merged 2 commits from luau-reference-fields into main 2026-09-06 06:06:04 +00:00
Owner

Closes #85.

A field defaulted to the GameObject class in Component.define registers as a GameObject_Reference field. From Luau it reads as the referenced GameObject userdata or nil, and accepts a GameObject or nil on write through component_set_reference, so the Reference Side Table covers cross-Scene targets. A non-GameObject value, or a destroyed GameObject, raises an error naming the field.

Save, load and External Reference resolution needed no Core changes. tests/luau/reference_test.odin covers each acceptance criterion: the .Reference flag, write and clear visible via component_reference, read-back identity, the text document holding an Object Path and resolving on load, and a reference into an unloaded Scene reading nil until that Scene loads.

Not changed: reading a reference whose same-Scene target was destroyed yields a dead userdata rather than nil, matching every other GameObject property today.

Closes #85. A field defaulted to the `GameObject` class in `Component.define` registers as a `GameObject_Reference` field. From Luau it reads as the referenced GameObject userdata or `nil`, and accepts a GameObject or `nil` on write through `component_set_reference`, so the Reference Side Table covers cross-Scene targets. A non-GameObject value, or a destroyed GameObject, raises an error naming the field. Save, load and External Reference resolution needed no Core changes. `tests/luau/reference_test.odin` covers each acceptance criterion: the `.Reference` flag, write and clear visible via `component_reference`, read-back identity, the text document holding an Object Path and resolving on load, and a reference into an unloaded Scene reading `nil` until that Scene loads. Not changed: reading a reference whose same-Scene target was destroyed yields a dead userdata rather than `nil`, matching every other GameObject property today.
A field defaulted to the GameObject class in Component.define registers as
a GameObject_Reference field. Luau reads it as the referenced GameObject
userdata or nil and writes a GameObject or nil through the Reference Side
Table, so a document stores it as an Object Path and an External Reference
into an unloaded Scene reads nil.
crowmaki deleted branch luau-reference-fields 2026-09-06 06:06:04 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
crowmaki/cinnabar!97
No description provided.