Module ActionInstance

All actions created by this class.

The most of this API you should use only on develop your own custom actions.

Functions

initialize(trigger_callback[, release_callback]) Action Instance constructor function
ActionInstance.static.copy(prefab) Copy constructor
event(event_name) Trigger event to action's FSM
get_value(variable_name) Return variable value from FSM variables
set_value(variable_name, value) Set variable value in action's FSM
get_param(param) Check if param value is from FSM variables.
set_every_frame() Set action triggered every frame.
set_with_context() Add context to this actions.
set_periodic([seconds[, skip_initial_call]]) Set periodic trigger of action.
set_delay(seconds) Add delay before action is triggered.
set_deferred([state]) Set action to deferred state.
is_deferred() Return action deferred state.
set_name(name) Set the name of the action
get_name() Return the name of the action
finish(trigger_event) Function called when action is done.
force_finish(trigger_event) Force finish action, even with "is_every_frame" or "is_periodic".
set_debug(state) Set debug state of action.

Fields

context Action context table
_name The action instance name
_trigger_callback desc
_release_callback desc
_state_instance desc
_is_every_frame desc
_is_deferred desc
_is_periodic desc
_periodic_timer desc
_periodic_timer_current desc

Local Functions

update(dt) Update function, called by StateInstance
trigger() Trigger action, called by StateInstance
release() Release action (cleanup), called by StateInstance
get_adam_instance() Return action's AdamInstance.
set_state_instance(state_instance) Set StateInstance for this action instance.
_get_delay_seconds() Get seconds to delay for trigger action
_trigger_action() Actual call of trigger callback.


Functions

initialize(trigger_callback[, release_callback])
Action Instance constructor function

Parameters:

  • trigger_callback function The main action function
  • release_callback function The release function. Clean up stuff, it you need (optional)
ActionInstance.static.copy(prefab)
Copy constructor

Parameters:

  • prefab ActionInstance The action to copy

Returns:

    ActionInstance Copy of prefab action
event(event_name)
Trigger event to action's FSM

Parameters:

  • event_name string Name of trigger event
get_value(variable_name)
Return variable value from FSM variables

Parameters:

  • variable_name string The name of variable in FSM
set_value(variable_name, value)
Set variable value in action's FSM

Parameters:

  • variable_name string The name of variable in FSM
  • value any New value for variable
get_param(param)
Check if param value is from FSM variables. If not - return itself or return variable from FSM Pass this values to action args via `actions.value()`

Parameters:

  • param any

Returns:

    any

See also:

set_every_frame()
Set action triggered every frame. Initial call will be skipped

Returns:

    ActionInstance Self
set_with_context()
Add context to this actions. It's cross call table, the second arg in trigger and release callbacks

Returns:

    ActionInstance Self
set_periodic([seconds[, skip_initial_call]])
Set periodic trigger of action.

Parameters:

  • seconds number The time between triggers (optional)
  • skip_initial_call boolean If true, skip first initial call on state enter (optional)

Returns:

    ActionInstance Self
set_delay(seconds)
Add delay before action is triggered. Every frame and periodic trigger will start after delay is happened. You should call finished method in action trigger function. You can pass action.param as second argument

Parameters:

  • seconds number, variable or nil Action delay

Returns:

    ActionInstance Self
set_deferred([state])
Set action to deferred state. To complete the action `finished` should be called

Parameters:

  • state boolean The deferred state (optional)
is_deferred()
Return action deferred state. If action is deferred - it can be executed in one frame

Returns:

    boolean Action deferred state
set_name(name)
Set the name of the action

Parameters:

Returns:

    ActionInstance Self
get_name()
Return the name of the action

Returns:

    string The action name
finish(trigger_event)
Function called when action is done. Never called on actions with "is_every_frame" or "is_periodic". Deferred actions should call manually this function

Parameters:

  • trigger_event string Event to trigger before finish call
force_finish(trigger_event)
Force finish action, even with "is_every_frame" or "is_periodic". This call will stop any updates of this action

Parameters:

  • trigger_event string Event to trigger before finish call
set_debug(state)
Set debug state of action. If true, will print debug info to console

Parameters:

  • state boolean The debug state

Returns:

    ActionInstance Self

Fields

context
Action context table
_name
The action instance name
_trigger_callback
desc
  • _trigger_callback function(ActionInstance)
_release_callback
desc
  • _release_callback function(ActionInstance) (optional)
_state_instance
desc
  • _state_instance StateInstance
_is_every_frame
desc
  • _is_every_frame boolean
_is_deferred
desc
  • _is_deferred boolean
_is_periodic
desc
  • _is_periodic boolean
_periodic_timer
desc
  • _periodic_timer number
_periodic_timer_current
desc
  • _periodic_timer_current number

Local Functions

update(dt)
Update function, called by StateInstance

Parameters:

  • dt number Delta time
trigger()
Trigger action, called by StateInstance
release()
Release action (cleanup), called by StateInstance
get_adam_instance()
Return action's AdamInstance. Used internally

Returns:

    AdamInstance
set_state_instance(state_instance)
Set StateInstance for this action instance. Called by StateInstance

Parameters:

  • state_instance StateInstance
_get_delay_seconds()
Get seconds to delay for trigger action

Returns:

    number Seconds to delay
_trigger_action()
Actual call of trigger callback. Used internally
generated by LDoc TESTING Last updated 2015-01-01 12:00:00