Module AdamInstance
All Adam Instances created by this class.
Instantiate it via `adam.new()`.
Functions
initialize(initial_state[, transitions[, variables[, final_state]]]) | Adam Instance constructor function. |
start() | Start the Adam Instance. |
resume() | Resume the execution of Adam Instance. |
pause() | Pause the execution of Adam Instance. |
is_active() | Return true if Adam Instance is now working |
update(dt) | Adam update functions. |
on_input(action_id, action) | Adam on_input function. |
on_message(message_id, message, sender) | Adam on_message function. |
final() | Adam final function. |
add(adam_instance) | Add Adam Instance to current as nested FSM. |
forward_events(adam_instance, events, is_consume, Self) | Forward incoming events to other adam instance |
bind(game_object) | Change the self context instante (the go instante instead of "." in all of action) also set the game object id as FSM id. |
event(event_name[, event_context]) | Trigger event in Adam FSM. |
can_transition(event_name) | Check available to make transition from current state with event |
get_value(variable_name) | Return variable value from Adam instance |
set_value(variable_name, value) | Set variable value in Adam instance |
set_id(hash) | Set id for Adam instance. |
get_id() | Get id of current Adam instance |
set_name(name) | Set name for Adam Instance. |
get_name() | Get name of current Adam Instance |
get_current_state() | Return current adam state |
get_self() | Return current game object binded to Adam (default ".") |
get_url() | Get context url, where Adam Instance was started. |
is_inited() | Return true, if Adam Instance was started |
set_debug(is_debug) | Set debug state of state. |
Local Functions
get_input_pressed(action_id) | Return input state of pressed action |
get_input_current(action_id) | Return input state of current action |
get_input_released(action_id) | Return input state of released action |
get_trigger_message() | Return last message from trigger collission |
_init_fsm(initial_state, transitions) | Parse Adam Instance params to create fsm |
_init_variables(variables) | Set variable to current Adam Instance and set initial general variables |
_on_leave_state(event, from, to) | Adam callback on leave state |
_on_enter_state(event, from, to) | Adam callback on enter state |
_process_input(action_id, action) | Store input info to process it later |
_clear_input() | Clear stored input info. |
_process_message(message_id, message, sender) | Process messages to send it to Adam FSM is possile |
_process_event_context(event_name, event_context) | Store context, vary on event_name |
Functions
- initialize(initial_state[, transitions[, variables[, final_state]]])
-
Adam Instance constructor function.
Parameters:
- initial_state StateInstance The initial FSM state. It will be triggered on start
- transitions StateInstance[] The array of next structure: {state_instance, state_instance, [event]}, describe transitiom from first state to second on event. By default event is adam.FINISHED (optional)
- variables table Defined FSM variables. All variables should be defined before use (optional)
- final_state StateInstance This state should contains only instant actions, execute on adam:final, transitions are not required (optional)
Returns:
-
AdamInstance
- start()
-
Start the Adam Instance. On create FSM is not started and should be started manually.
On Adam Instance start system will remember url for this Adam Instance for msg.post (send event actions).
You can use `local adam = AdamInstance({}):start()`
Returns:
-
AdamInstance
- resume()
-
Resume the execution of Adam Instance.
You can pause execution with pause method.
Returns:
-
AdamInstance
- pause()
-
Pause the execution of Adam Instance.
You can resume execution with resume method.
Returns:
-
AdamInstance
- is_active()
-
Return true if Adam Instance is now working
Returns:
-
boolean
Is active state
- update(dt)
-
Adam update functions. Place in script/gui_script update function
Parameters:
- dt numbet The delta time
- on_input(action_id, action)
-
Adam on_input function. Place in script/gui_script on_input function
Parameters:
- action_id hash The input action_id
- action table The input action info
- on_message(message_id, message, sender)
-
Adam on_message function. Place in script/gui_script on_message function
Parameters:
- message_id hash The message_id
- message table The message info
- sender hash The message sender id
- final()
- Adam final function. Place in script/gui_script final function on when you wanna to finish FSM. Important function, since it track global list of Adam instances
- add(adam_instance)
-
Add Adam Instance to current as nested FSM.
It will work, until parent instance will work. On final parent instance, it call final on
all nested adams
Parameters:
- adam_instance AdamInstance The nested Adam Instance
Returns:
-
AdamInstance
Self
- forward_events(adam_instance, events, is_consume, Self)
-
Forward incoming events to other adam instance
Parameters:
- bind(game_object)
-
Change the self context instante (the go instante instead of "." in all of action)
also set the game object id as FSM id. Do bind before adam:start function.
Parameters:
- game_object hash The game object to bind
Returns:
-
AdamInstance
Self
- event(event_name[, event_context])
-
Trigger event in Adam FSM. If any transitions on this event exists, go to next state instantly
Parameters:
- can_transition(event_name)
-
Check available to make transition from current state with event
Parameters:
- event_name string The trigger event
Returns:
-
boolean
True, if FSM will make transition on this event
- get_value(variable_name)
-
Return variable value from Adam instance
Parameters:
- variable_name string or variable The name of variable in FSM
Returns:
-
variable
- set_value(variable_name, value)
-
Set variable value in Adam instance
Parameters:
- variable_name string or variable The name of variable in FSM
- value any New value for variable
- set_id(hash)
-
Set id for Adam instance. Several Adam instances can have single id
Useful for select multiply Adam instances on fsm actions
Parameters:
- hash hash The Adam Instance id
- get_id()
-
Get id of current Adam instance
Returns:
-
hash
The Adam Instance id
- set_name(name)
-
Set name for Adam Instance. Useful for Debug.
Parameters:
- name string The Adam Instance name
- get_name()
-
Get name of current Adam Instance
Returns:
-
string
The Adam Instance name
- get_current_state()
-
Return current adam state
Returns:
-
StateInstance
The current State Instance
- get_self()
-
Return current game object binded to Adam (default ".")
Returns:
-
url
The game object id
- get_url()
-
Get context url, where Adam Instance was started. Used for post messages
Returns:
-
url or nil
The Adam Instance url
- is_inited()
-
Return true, if Adam Instance was started
Returns:
-
boolean
The Adam Instance inited state
- set_debug(is_debug)
-
Set debug state of state. If true, will print debug info to console
Parameters:
- is_debug boolean The debug state
Returns:
-
AdamInstance
Self
Local Functions
- get_input_pressed(action_id)
-
Return input state of pressed action
Parameters:
- action_id hash The input action_id
Returns:
-
table or nil
The input info
- get_input_current(action_id)
-
Return input state of current action
Parameters:
- action_id hash The input action_id
Returns:
-
table or nil
The input info
- get_input_released(action_id)
-
Return input state of released action
Parameters:
- action_id hash The input action_id
Returns:
-
table or nil
The input info
- get_trigger_message()
-
Return last message from trigger collission
Returns:
-
table or nil
The last trigger message
- _init_fsm(initial_state, transitions)
-
Parse Adam Instance params to create fsm
Parameters:
- initial_state
- transitions
- _init_variables(variables)
-
Set variable to current Adam Instance and set initial general variables
Parameters:
- variables
- _on_leave_state(event, from, to)
-
Adam callback on leave state
Parameters:
- event
- from
- to
- _on_enter_state(event, from, to)
-
Adam callback on enter state
Parameters:
- event
- from
- to
- _process_input(action_id, action)
-
Store input info to process it later
Parameters:
- action_id
- action
- _clear_input()
- Clear stored input info. Called as last step of update on every frame
- _process_message(message_id, message, sender)
-
Process messages to send it to Adam FSM is possile
Parameters:
- message_id
- message
- sender
- _process_event_context(event_name, event_context)
-
Store context, vary on event_name
Parameters: