lt_wentoncha wrote:How do scripts affect saved games? Say I install a script, spend two days building a complex (saving in between), and decide I no longer want the script and uninstall, or there's a newer version out and I update the script.
When a script runs, its code must be cached in memory. And when you save, that cache-copy must be saved in order to continue (on load-game) exactly from the line where the execution was on the moment of save. So after load you still have that copy in memory, even if there no longer is a script file to load it from.
Where this can break, is when such cached script calls another script, for which there is no file any more (and since that script was not running during save, there is no cached copy). Those calls silently fail, so if the caller script assumes the call to do something, then Houston has a problem.
The scripts that usually remain in memory (forever) are those that execute an infinite loop. "Commands" that will continue to run, rather than doing one operation and then quitting.
The main file of CAG/CLS/EST are such loops. But they do check during every iteration, whether they should stop or restart. If you update those scripts, the main loop notices version change, and restarts itself, ie reloads the latest version from file. If you do their uninstall procedure, they again notice that there is a version change, and what they do restart, immediately quits. No more running script, script cache clears, and future saves have no traces of the uninstalled script.
Note though that the check is once per iteration. The ship may have just passed the check during save and is now on long trade run. Next check will occur after the run, ie perhaps several minutes after you have loaded the game.
Thus, to uninstall safely:
* Either the script is well written and handles uninstall gracefully, but you may have to play some time before it actually happens for every running copy.
* Or you have to make sure that the script to uninstall does not have any running copies, bits, or pieces anywhere before you save and quit to run uninstall.
And then there is the Plugin Manager. I can tell you nothing about the Plugin Manager.