method
Reflect.set
Reflect.set(entity, prop, field, value)
Writes value into field field of property prop on entity. For a fixed field, pass the raw Q16.16 bits. This is how a generic loader restores saved state and how a debug overlay applies an edit. Same as World.set, under the reflection namespace.
Parameters
entitythe entity to modifypropa property id (from Reflect.prop)fielda field id (from Reflect.field)valuethe integer value to storeExample
program Demo {
property Health { hp: int = 0 }
model Unit { Health }
entry {
spawn Unit { Health { hp: 7 } }
let H = Reflect.prop("Health")
Reflect.set(0, H, Reflect.field(H, "hp"), 99)
print(Reflect.get(0, H, 0)) # 99
}
}