I'm investigating writing a script that calculates a artificial running "score" of a game as it progresses. I'd like it to display periodic updates on the current score, and persist a cumulative total for an in-game year across save/loads. So far I've got:
- I can start a script from onMapLoad*.init and do any needed cleanup from onMapUnload*.init. (That's the safest place to put something that should only run in Fortress mode?)
- I can use repeat to schedule a command to examine the site map/logs and calculate/report a score daily.
So far, so good. Is there any convenient way to save a value (like "current total score") that will persist across save/loads of a game?
I imagine that writing a value to an arbitrary file would be a gigantic security hole, but maybe it's possible anyway? I see there's a stockpiles plugin that (I think) delivers a .dll to deliver the file access functionality. I'd rather not get that fancy.
Failing that, I guess there's a lot of places in a saved game where you could stash a value somewhere it wouldn't hurt a running game. Maybe in some stat for a historical figure, or somewhere in the game raws as a non []-enclosed value that would be interpreted as a comment?
Does anyone have any advice on how to best save arbitrary data across game saves so the script can retrieve it on the next onMapLoad?