Module ActionInstance
All actions created by this class.
The most of this API you should use only on develop your own custom actions.
-
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:
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
-
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_deferred
-
desc
-
_is_periodic
-
desc
-
_periodic_timer
-
desc
-
_periodic_timer_current
-
desc
- _periodic_timer_current
number
-
update(dt)
-
Update function, called by StateInstance
Parameters:
-
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