er2.triggerCallback 35
Force the triggering of a callback set trough setCallback
Return value
Return Type | Description |
---|---|
bool | True if the callback was correctly triggered |
Parameters
Parameter | Type | Description |
---|---|---|
1 | string | Id of the callback to trigger |
2 | any | Params of the callback function (as many as the function accepts) |
Examples
Example 174
-- Define any Lua function as your callback.
function MyCustomCallback(spawnedUnit)
print('MyCustomCallback called with parameter: ' .. spawnedUnit)
end
-- Register the callback from Lua. In this example the callback will be called every time a soldier is spawned.
er2.setCallback("soldier_spawned", MyCustomCallback)
-- Force triggering the callback with a nil parameter
er2.triggerCallback("soldier_spawned", nil)