er2.triggerCallback 35

Force the triggering of a callback set trough setCallback


Return value

Return TypeDescription
boolTrue if the callback was correctly triggered

Parameters

ParameterTypeDescription
1stringId of the callback to trigger
2anyParams 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)

Back to Scripting API