Correct Cleanup example: Change OnSet to OnAdd (#289)

* Correct Cleanup example: Change OnSet to OnAdd

`jecs.OnSet` no longer exists. This should be `jecs.OnAdd` instead, which does exist.

* Clarify OnAdd hook in cleanup.luau

Add comment to clarify OnAdd hook behavior
This commit is contained in:
Madison 2025-12-10 12:14:57 -08:00 committed by Ukendio
parent df454c75a3
commit 007097b791

View file

@ -13,8 +13,9 @@ world:set(Model, jecs.OnRemove, function(entity)
model:Destroy()
end)
world:set(Model, jecs.OnSet, function(entity, model)
-- OnSet is invoked after the data has been assigned.
world:set(Model, jecs.OnAdd, function(entity, id, model)
-- OnAdd is invoked after the data has been assigned.
-- This hook only fires the first time the component is added.
-- It also returns the data for faster access.
-- There may be some logic to do some side effects on reassignments
model:SetAttribute("entityId", entity)