Talk:ZScript global variables
October 9, 2019
The reason I originally removed the Thinker example is because it's slower and relies upon calling the ThinkerIterator, to clarify about why I had done so in September 2018.
Now that I have been made aware static event handlers don't save, I've been thinking on this.
The best way to handle this would be to have the static thinker assigned to both a static and regular event handler. As saving can only happen in-game, the static event handler can grab the thinker from the regular handler upon loading a saved game from the regular. Likewise, upon entering a new map, the regular can grab it from the static - and if it doesn't exist, can call the thinker's Get() function.
Also worth noting is NewGame() being called before WorldLoaded, though only with static event handlers. This would be a good function for directly creating a new static thinker and not bothering with using the Get() function.
- Major Cooke