Skip to content

Core

Global functions always available.

FunctionSignatureDescription
print(value: any)Print to the host console
assert(condition: bool, msg: string)Error if condition is false
print("Hello from Writ!")
assert(health > 0, "Player should be alive")

Module name: "reflect"

FunctionSignatureDescription
typeof(value: any) -> stringType name of a value
instanceof(value: any, type: string) -> boolCheck type at runtime
hasField(value: any, field: string) -> boolCheck if a field exists
getField(value: any, field: string) -> anyGet a field by name
setField(value: any, field: string, val: any)Set a field by name
fields(value: any) -> Array<string>All field names
methods(value: any) -> Array<string>All method names
hasMethod(value: any, method: string) -> boolCheck if a method exists
invoke(value: any, method: string, ...args: any) -> anyCall a method by name
typeof(42) // "int"
instanceof(player, "Player") // true
hasField(player, "health") // true
getField(player, "health") // 100.0
fields(player) // ["health", "name", ...]