Resetting script variables

Hi guys.. o)

Doing some scripting where I need to reset some global scoped variables whenever the script addin is reloaded or changed externally.
The script leaves variables in an inconsistent state whenever there was an error (which can happen, especially while developing things).

OnInit() is too early, since "Script" is not existent yet. OnStartup() does not fire unless DO is restarted and the other events also don't seem to help out. Putting something like the below in the global scope does not work either, since it's going run for any event or command and interferes with properly working internals of the addin.
Running if (typeof Script !== "undefined"){ Reset(); }
Any ideas? Thanks! o)

Btw.: DOpus.Delay(0); raises an exception. o(

If it's for during development, I'd probably make the script add a command that can be run via a button or hotkey to reset whatever is needed.

Yes, that's an option.
So there's no hook or any other technique I could use to automate this.
Just wanted to make sure I don't overlook something. Thank you! o)

I had a vague feeling there was an event for the script being re-loaded, but I think I was thinking of OnScriptConfigChange which is different.

Me too! o))