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

Closed
opened 2026-09-06 01:25:28 +00:00 by crowmaki · 0 comments
Owner

Parent

#75

What to build

A field defaulted to the GameObject class in Component.define becomes a GameObject_Reference field. From Luau the field reads as the referenced GameObject userdata or nil and accepts a GameObject or nil on write, going through the Reference Side Table rather than raw storage. A Scene Document stores the field as an Object Path and resolves it on load. An External Reference whose target Scene is unloaded reads as nil, the way the glossary says.

Acceptance criteria

  • Component.define("x", { target = GameObject }) registers a field with the .Reference flag
  • Assigning self.target = other from Luau is visible via component_reference; assigning nil clears it
  • Reading self.target returns a userdata that compares equal to the GameObject it was set to
  • Saving the Scene writes the field as an Object Path; loading the document resolves it to the right GameObject
  • A reference into a Scene that is not loaded reads as nil from Luau, and reads the GameObject once that Scene is loaded
  • Assigning a non-GameObject value raises an error naming the field

Blocked by

## Parent #75 ## What to build A field defaulted to the `GameObject` class in `Component.define` becomes a `GameObject_Reference` field. From Luau the field reads as the referenced GameObject userdata or `nil` and accepts a GameObject or `nil` on write, going through the Reference Side Table rather than raw storage. A Scene Document stores the field as an Object Path and resolves it on load. An External Reference whose target Scene is unloaded reads as `nil`, the way the glossary says. ## Acceptance criteria - [ ] `Component.define("x", { target = GameObject })` registers a field with the `.Reference` flag - [ ] Assigning `self.target = other` from Luau is visible via `component_reference`; assigning `nil` clears it - [ ] Reading `self.target` returns a userdata that compares equal to the GameObject it was set to - [ ] Saving the Scene writes the field as an Object Path; loading the document resolves it to the right GameObject - [ ] A reference into a Scene that is not loaded reads as `nil` from Luau, and reads the GameObject once that Scene is loaded - [ ] Assigning a non-GameObject value raises an error naming the field ## Blocked by - #82
Sign in to join this conversation.
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#85
No description provided.