Skip to content

CustomMovableBehavior

Movable entitiesno constructorsource

Derived from MovableBehavior

Opaque handle to a custom movable behavior from a script mod

Fields

Methods

set_force_state

function CustomMovableBehavior.set_force_state(behavior: CustomMovableBehavior?, force_state: fun(movable: Movable?, base_fun: fun(p1: Movable?): boolean): boolean)
behavior: CustomMovableBehavior?
force_state: fun(movable: Movable?, base_fun: fun(p1: Movable?): boolean): boolean
Returning nil (or nothing): treated as false.

Set the force_state function of a CustomMovableBehavior, this will be called every frame when the movable is updated. If an force_state is already set it will be overridden. The signature of the function is bool force_state(Movable movable, function base_fun), when the function returns true the movable will enter this behavior. If no base behavior is set base_fun will be nil.

source

set_get_next_state_id

function CustomMovableBehavior.set_get_next_state_id(behavior: CustomMovableBehavior?, get_next_state_id: fun(movable: Movable?, base_fun: fun(p1: Movable?): integer): integer)
behavior: CustomMovableBehavior?
get_next_state_id: fun(movable: Movable?, base_fun: fun(p1: Movable?): integer): integer
Returning nil (or nothing): treated as behavior->state_id.

Set the get_next_state_id function of a CustomMovableBehavior, this will be called every frame when the movable is updated. If an get_next_state_id is already set it will be overridden. The signature of the function is int get_next_state_id(Movable movable, function base_fun)), use this to move to another state, return nil. or this behaviors state_id to remain in this behavior. If no base behavior is set base_fun will be nil.

source

set_on_enter

function CustomMovableBehavior.set_on_enter(behavior: CustomMovableBehavior?, on_enter: fun(movable: Movable?, base_fun: fun(p1: Movable?)))
behavior: CustomMovableBehavior?
on_enter: fun(movable: Movable?, base_fun: fun(p1: Movable?))

Set the on_enter function of a CustomMovableBehavior, this will be called when the movable enters the state. If an on_enter is already set it will be overridden. The signature of the function is nil on_enter(Movable movable, function base_fun)). If no base behavior is set base_fun will be nil.

source

set_on_exit

function CustomMovableBehavior.set_on_exit(behavior: CustomMovableBehavior?, on_exit: fun(movable: Movable?, base_fun: fun(p1: Movable?)))
behavior: CustomMovableBehavior?
on_exit: fun(movable: Movable?, base_fun: fun(p1: Movable?))

Set the on_exit function of a CustomMovableBehavior, this will be called when the movable leaves the state. If an on_exit is already set it will be overridden. The signature of the function is nil on_exit(Movable movable, function base_fun)). If no base behavior is set base_fun will be nil.

source

set_update_logic

function CustomMovableBehavior.set_update_logic(behavior: CustomMovableBehavior?, update_logic: fun(movable: Movable?, base_fun: fun(p1: Movable?)))
behavior: CustomMovableBehavior?
update_logic: fun(movable: Movable?, base_fun: fun(p1: Movable?))

Set the update_logic function of a CustomMovableBehavior, this will be called every frame when the movable is updated. If an update_logic is already set it will be overridden. The signature of the function is nil update_logic(Movable movable, function base_fun)), use it to change the color, texture, some timers, etc. of the movable. If no base behavior is set base_fun will be nil.

source

set_update_world

function CustomMovableBehavior.set_update_world(behavior: CustomMovableBehavior?, update_world: fun(movable: Movable?, base_fun: fun(p1: Movable?)))
behavior: CustomMovableBehavior?
update_world: fun(movable: Movable?, base_fun: fun(p1: Movable?))

Set the update_world function of a CustomMovableBehavior, this will be called every frame when the movable is updated. If an update_world is already set it will be overridden. The signature of the function is nil update_world(Movable movable, function base_fun)), use this to update the move, velocity, current_animation, etc. of the movable, then call mov:generic_update_world to update the movable. If no base behavior is set base_fun will be nil.

source