One of the biggest concerns for me and many other scripters when writing event-handler-oriented codes is that if someone removes our EHs by mistake (e.g. using incorrect ID, like how many newbies just remove `0`) or intentionally (many newbies doing `removeAllXXXEventHandlers`), our design could fail entirely.
Thus, I would like to ask for scripting commands that allow us to detect and counter these problems.
1. (low priority, feel free to ignore this) Get next event handler ID:
This command checks if the event handler still exists and has not been removed yet:
> `get`isEventHandlersCountValid [entity, "name"];`, ID]`
> entity: can be NAMESPACE (maybe only missionNamespace? for mission/user EHs)/OBJECT/GROUP/CONTROL/DISPLAY
> name: event handler name
> returns: total number of EHs added (which is also the same as next added ID)
Alternatively, for mission/user EHs the syntax can be:
> `getEventHandlersCount "name"`
Since EH IDs are incremental, this allows us to know if any new EHs have been added after ours. This command will also be useful for the Intercept project.
2. A command that checks if the event handler still exists and has not been removed yet:ID: number: EH ID
> `isEventHandlerValid [entity, "name", ID]`returns: number:
> entity: can be NAMESPACE (maybe only missionNamespace? for mission/user EHs)/OBJECT/GROUP/CONTROL/DISPLAY` 1`: Still exists
> name: event handler name` 0`: Was removed
> ID: number: EH ID
> returns: bool`-1`: Invalid (never added, which happens if ID >= nextID, or ID is negative)
Alternatively, for mission/user EHs the syntax can be:
> `isEventHandlerValid ["name", ID]`
or
> `"name" isEventHandlerValid ID`