Find components, send them events, and control which of your events are active.
22 natives. Read-only natives only look things up; the rest change something. Parameter types use the language's names (Types ).
$ component . cast (component: Component , exact: bool , script_name: string ) -> Component
Converts a component ref from one type to another if safe to do so, or generates a warning and returns NULL if the types are not compatible.
Parameter Type Meaning componentComponentThe component to attempt to cast. exactboolTrue to only match the exact type (no derived types). script_namestringThe script name.
Returns Component: The converted value, or NULL if the value was nor compatible.
$ component . get () -> Component
Get the calling component.
Returns Component: The component.
$ component . get_entity (component: Component ) -> Entity
Gets the entity holding a component.
Parameter Type Meaning componentComponentThe component to get the entity from.
Returns Entity: The entity
$ component . get_event_source () -> Component
Gets the component that triggered the current event, if any.
Returns Component: A component or nullcomponent.
$ component . get_index () -> int
Get the calling component's index within its entity's component list.
Returns int: The index of the specified component within its entity's component list; otherwise, -1 in the event of an error.
$ component . get_job_self_sort_order (component: Component ) -> int
Gets the sort key for the specified component. See component.set_job_self_sort_order.
Parameter Type Meaning componentComponentThe component to set.
Returns int: The self sort key value.
$ component . get_parallel_id () -> int
Returns the id (index) of the invocation for a parallel loop. Returns 0 when not called from a parallel loop.
Returns int: The id (index) of the invocation for a parallel loop.
$ component . get_singleton (script_name: string , owner: User ) -> Component
Retrieve a component of which there is assumed to be only one instance.
Parameter Type Meaning script_namestringThe script name. ownerUser(Optional) Filters results to only values owned by the indicated user. Omit to return all results. Warns on NULL.
Returns Component: The component or null if not found.
$ component . has_event (target: Component , event_name: string ) -> bool
Return true if the specified target has or is a component that has an event of the given name.
Parameter Type Meaning targetComponentThe target entity or component to check. event_namestringThe name of the event to look for.
Returns bool: True if the target has or is a component that has the given event, false otherwise.
$ component . has_var (component: Component , var_name: string ) -> bool
Return true if the given component has a var (mutable) of the given name. 'const's are *not* checked.
Parameter Type Meaning componentComponentThe component to check. var_namestringThe name of the var to look for.
Returns bool: True if the component has the var, false otherwise.
$ component . is_fully_created (component: Component ) -> bool
Gets whether the entity owning a component is created yet or not (i.e. if it's safe to call functions)
Parameter Type Meaning componentComponentThe component to check.
Returns bool: True if it is, false otherwise.
$ component . is_of_type (component: Component , exact: bool , script_name: string ) -> bool
Gets whether or not a component is a given type.
Parameter Type Meaning componentComponentThe component to check. exactboolTrue to only match the exact type (no derived types). script_namestringThe script name.
Returns bool: True if the component is of the specified type, false otherwise.
$ component . parallel_loop (func: string , target: Component , args: list , count: int , allow_non_const: bool ) -> list
Returns a list that is the results of calling the supplied function on the target component as requested. Must be a const function unless allow_non_const is true.
Parameter Type Meaning funcstringName of the function to invoke in parallel. targetComponentComponent to run the function on. Current component if not specified. argslistArgs to pass to the function. countintNumber of invocations to run in parallel. allow_non_constboolAllow non-const functions to be called. Care must be taken to avoid race conditions or stomping.
Returns list: Results of calling func, sized to count.
$ component . print (component: Component )
Print component information to the console.
Parameter Type Meaning componentComponentThe component.
$ component . queue_event (name: string , target: Component , args: list , end_of_frame: bool )
Enqueue an event on a specific component.
Parameter Type Meaning namestringName of the event. targetComponentThe recipient of the event. argslistEvent arguments. end_of_frameboolIf true, the event is queued to run at the end of the frame, otherwise it runs at the end of the active event.
$ component . read_nondeterministic (component: Component , field: string ) -> var
Read a field on a component without synchronizing. Returns nondeterministic and possibly unexpected values. Use with extreme care.
Parameter Type Meaning componentComponentThe component to read from fieldstringThe name of the field to read
Returns var: The value of the field.
$ component . set_event_enabled (name: string , enabled: bool , component: Component )
Enables or disables an event on a component. Generally only safe to use outside the event being enabled/disabled.
Parameter Type Meaning namestringThe name of the event. enabledbooltrue to enable the event, false to disable. componentComponentThe component to set event state. Or null to set the state of the calling component.
$ component . set_job_self_sort_order (component: Component , value: int )
Sets the sort key for the specified component. Used with type.setup_job_self_sort to improve performance in some cases.
Parameter Type Meaning componentComponentThe component to set. valueintSort key value to use to sort among components.
$ component . take_control (component: Component )
Attempts to take control of another component.
Parameter Type Meaning componentComponentThe component to take control of.
$ component . try_cast (component: Component , exact: bool , script_name: string ) -> Component
Converts a component ref from one type to another if safe to do so, or silently NULL if the types are not compatible.
Parameter Type Meaning componentComponentThe component to attempt to cast. exactboolTrue to only match the exact type (no derived types). script_namestringThe script name.
Returns Component: The converted value, or NULL if the value was nor compatible.
$ component . try_queue_event (name: string , target: Component , args: list , end_of_frame: bool )
Try to enqueue an event on a specific component. Does not assume the event exists on the component.
Parameter Type Meaning namestringName of the event. targetComponentThe recipient of the event. argslistEvent arguments. end_of_frameboolIf true, the event is queued to run at the end of the frame, otherwise it runs at the end of the active event.
Compiler helpers The engine marks these as emitted by its own compiler. Most have shorthand in this language; prefer it where the guide shows one. Some are still the only way to do something, and the cookbook uses those deliberately.
$ component . call_function (alias: string , func_name: string , signature_hash: int , argc: int ) -> var
function_alias(...) SYNTAX*** Calls a function on another component. Caller must have control of the function already.
Parameter Type Meaning aliasstringThe alias of the function to be invoked. func_namestringThe true name of the function to invoke. signature_hashintThe hash of the function signature to invoke. argcintThe number of function args on the stack.
Returns var: The return value of the invoked function