Callbacks API Documentation
This page documents the callbacks available in Easy Red 2 for Lua scripting.
Here you will find the Id of the callbacks to use with functions like er2.setCallback, Soldier.setCallback and Vehicle.setCallback in order to register a callback event to a specific lua function.
You will also find the partameters that the lua function will need to implement in order to correctly trigger the callback. Click on the description or the arrow to reveal parameters.
Here's an example of how to register a Lua callback on a function called "MyCustomCallback":
-- Define your Lua callback function
function MyCustomCallback(spawnedUnit)
print('MyCustomCallback called with parameter: ' .. spawnedUnit)
end
-- Register the callback in Lua.
er2.setCallback("soldier_spawned", MyCustomCallback)
Global callbacks available for general game events. Can be set with er2.setCallback function.
# | Type | Description |
---|---|---|
1 | Soldier | The soldier variable (explicit). |
# | Type | Description |
---|---|---|
1 | Soldier | The soldier variable (explicit). |
# | Type | Description |
---|---|---|
1 | Soldier | The soldier variable (explicit). |
# | Type | Description |
---|---|---|
1 | Soldier | The soldier variable that was spawned. |
# | Type | Description |
---|---|---|
1 | Soldier | The soldier variable (explicit). |
# | Type | Description |
---|---|---|
1 | Soldier | The soldier that lost the target |
# | Type | Description |
---|---|---|
1 | Squad | The new squad variable. |
# | Type | Description |
---|---|---|
1 | Squad | The squad variable. |
# | Type | Description |
---|---|---|
1 | Vehicle | The vehicle variable (explicit). |
# | Type | Description |
---|---|---|
1 | Vehicle | The vehicle variable (explicit). |
# | Type | Description |
---|---|---|
1 | Vehicle | The vehicle variable (explicit). |
# | Type | Description |
---|---|---|
1 | Vehicle | The vehicle variable (explicit). |
# | Type | Description |
---|---|---|
1 | Vehicle | The vehicle variable (explicit). |
Callbacks triggered by soldier-related events. Can be set with Soldier.setCallback function.
# | Type | Description |
---|---|---|
1 | Number | The damage amount. |
No parameters defined for this callback.
# | Type | Description |
---|---|---|
1 | string | The order type (e.g. waypoint_reached, soldier_healed, vehicle_repaired). |
No parameters defined for this callback.
# | Type | Description |
---|---|---|
1 | Number | The new pose (integer). |
No parameters defined for this callback.
# | Type | Description |
---|---|---|
1 | Soldier | The soldier that spotted the enemy (might be nil) |
# | Type | Description |
---|---|---|
1 | Soldier | The shooter soldier. |
No parameters defined for this callback.
# | Type | Description |
---|---|---|
1 | Soldier | The new target |
No parameters defined for this callback.
Callbacks triggered by vehicle-related events. Can be set with Vehicle.setCallback function.
# | Type | Description |
---|---|---|
1 | Number | Damage amount to the engine. |
# | Type | Description |
---|---|---|
1 | Number | Damage amount to the fueltank. |
# | Type | Description |
---|---|---|
1 | Number | Damage amount to the hull. |
# | Type | Description |
---|---|---|
1 | Number | Damage amount to the wheels. |
# | Type | Description |
---|---|---|
1 | Number | Damage amount to the wing. |
No parameters defined for this callback.
No parameters defined for this callback.
# | Type | Description |
---|---|---|
1 | Soldier | The soldier variable. |
No parameters defined for this callback.
No parameters defined for this callback.
No parameters defined for this callback.