Components from Luau: AddComponent, GetComponent, GetComponents, Destroy (#83) #95
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crowmaki/cinnabar!95
Loading…
Reference in a new issue
No description provided.
Delete branch "components-from-luau-83"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #83. Part of #75.
What
A Script composes GameObjects at runtime.
go:AddComponent(class)attaches a Component, runsAwake, and returns the instance.classis the tableComponent.definereturned or a Schema name string; an unknown name raises.GetComponentandGetComponentson a GameObject or onselfaccept the same two forms. An unknown name answersnilor an empty table.gameObject,IsAlive,Destroyand the two lookups. Any field read or write raises naming the Schema.Destroy(component)andcomponent:Destroy()queue removal for the next Structural Flush. The globalDestroydispatches on the userdata tag.starttakes companion Plugins ahead of luau, so a test can register an Odin Component.Two readings to confirm
GetComponentandGetComponentsare also answered there, since they only need an owner.component_dataalready allows. The mid-frame destroy case relies on it.Tests
tests/luau/composition_test.odincovers every acceptance criterion from Luau source strings, checked againstgameobject_component_count,component_countandcomponent_is_alive.just checkandjust testpass (443 tests).