The action system formalizes how players interact with the game, making things like networking possible.
The player interacts with the controller whose inputs will result in different actions depending on the context for the user interface.

Network interactions with Online Networking.
Network controllers with Hybrid Controllers.
Context is what is currently happening in the game which defines the user interface.
For example, control inputs will result in different actions on a menu screen vs the actual game.
Actions are results of inputs based on the context.
For example, an up input could result in the acton of jump or climb a ladder depending.
Interactions are actions that affect all players.
For example, destroying a wall would need to happen for every player.
The Phame Actions module is leveraged across several Phame modules and is the common language of "getting things done". By implementing actions into your game, you can easily leverage the Phame Networking module for any interactions in the future.
Module integration happens in two parts. First in the integration group of the module itself.
scr_action_interfacescr_action_interface defines a constant for each unique action in the game. Usually, the first ten numbers are reserved for the game's lobby menu. It is best practice to also fill out the scr_action_to_string() function for debug purposes.
All action constants should start with ACT_ for consistency.
Whenever an object requests or performs actions, it must be integrated with the action system.
In the object's Create event, three functions must be defined with switch statements for each applicable action constant:
perform_action(action)request_action(action)read_interaction(action)Since common functions are required for interoperability, the function definition cannot define any action-specifc parameters. Instead, these are accessed with argument[n] where n is 1 and above. argument[0] is reserved for action.
Documentation of these parameters occur naturally in the perform_action() function. Give parameters human readables names by first saving to a local variable: var damage = argument[1]. Then when a developer is trying to implement that action in another event, they can simply look at hte Create event. request_action() must identify the action-specific parameters to pass to perform_action().
Anywhere in the code that an action is normally performed, is replaced with a call to request_action() with the appropriate action constant and any necessary parameters.
request_action() in the create event can then determine whether it is an interaction and needs to be sent over the server, or an action that can be peformed locally. By centralizing this decision to the create event, it is easier to quickly implement networking without deep-diving the entire code.
Example using action ACT_BUILD_TOWER:
#region Actions
/// @function perform_action(action, [arguments])
/// @description Impacts the games
/// @param {real} Constant associated with action, other arguments depend on action
perform_action = function(action) {
switch action {
case ACT_BUILD_TOWER:
var build_tower = argument[1]
instance_create_layer((mouse_x div GRID) * GRID, (mouse_y div GRID) * GRID, "lay_instances", tower_list[build_tower])
obj_game_control.money -= tower_costs[build_tower]
break
}
}
/// @function request_action(action, [arguments])
/// @description Intermediate function that separates interactions and sends them over the server
/// @param {real} Constant associated with action, other arguments depend on action
request_action = function(action) {
switch action {
case ACT_BUILD_TOWER:
var build_tower = argument[1]
// TODO: Here is where we would request an interaction, and read_interaction would perform it
//request_interaction_u8(obj_client.connect_id, action, build_tower)
// But without the server, we'll just perform it
perform_action(action, build_tower)
break
}
}
/// @function read_interaction(action, [arguments])
/// @description Interaction was sent over the server, so perform it
/// @param {real} Constant associated with action, other arguments depend on action and read from buffer
read_interaction = function(action) {
switch action {
case ACT_BUILD_TOWER:
var build_tower = buffer_read(buff, buffer_u8)
perform_action(action, build_tower)
break
}
}
#endregion
Is damaging a character an action or interaction?
Where is the determination of if its an interaction made?
request_action(), not in the object event requesting the action.