Add a new, experimental function hackDoNotSave(global name).
It adds global by name to list of variables to not save to savegames. This too is not saved to savegames, so must be called again whenever game is restarted from a savegame.
New function: hackDoNotSave()
Re: New function: hackDoNotSave()
Why not just clear useless variables, when event save game is called? Or var's anyway saved but empty?
Re: New function: hackDoNotSave()
That should work, too.Prot wrote:Why not just clear useless variables, when event save game is called? Or var's anyway saved but empty?
Re: New function: hackDoNotSave()
You'd need to regenerate them when saving is over, not just after loading, which is extra coding. Or you'd want to store them in another variable, which will be saved but under a different name, and then bring them back, which is also extra coding.Prot wrote:Why not just clear useless variables, when event save game is called? Or var's anyway saved but empty?
It's cool to be able to replace this extra work with a single line:
Code: Select all
var V;
hackDoNotSave('V');
Code: Select all
(function(global) {
var V;
global.getV = function() { return V; }
global.setV = function(v) { V = v; }
})(this);
If used as in the first code snippet above, i guess it'd work, so it's cool. I was wrong about that in the original proposal.Per wrote:must be called again whenever game is restarted from a savegame.
Last edited by NoQ on 20 Mar 2017, 15:59, edited 2 times in total.
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
Re: New function: hackDoNotSave()
I'm a bit worried that using tricks like anonymous closures would make the code hard to read and understand, though. One of our primary aims should be to make the code easy to read, understand and improve by anyone who has done some coding before.
Re: New function: hackDoNotSave()
Yeah. Well, since we started this discussion from hook problems, adding some anonymous closures wouldn't make things much worse. But i agree that letting the scripters stick to simple variables and functions is very beneficial.
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam