Prop.setCallback 12
Listens to an event from the script of the prop. It takes the same event names as er2.setCallback (phase_changed, objective_captured, battle_ended...) and the function receives the same parameters, but every prop keeps its own function. er2.setCallback holds a single function per event for the whole battle, so with it a second prop would replace the first.The function is called wherever the script of the prop runs, whether or not the prop is loaded at that moment.
Return value
| Return Type | Description |
|---|---|
| void | True if the callback was registered. |
Parameters
| Parameter | Type | Description |
|---|---|---|
| 1 | string | Name of the event, for example objective_captured. |
| 2 | function | Called with the parameters of that event. Setting the same event again replaces the function of this prop only. |
Examples
A flag that follows its objective
-- on a flag prop: it shows the flag of whoever holds the objective it stands in
myself:setCallback("objective_captured", function(objective, faction)
if objective:isInside(myself:getPosition()) then
myself:setAlbedo(er2.getFactionFlag(faction))
end
end)