I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: RebornIsaac on August 14, 2015, 04:35:34 PM

Title: Globals restarting?
Post by: RebornIsaac on August 14, 2015, 04:35:34 PM
Whenever I restart my game, the globals restart, let's say item1 is at 1 when I restart/close it, and when I come back its again at 0, why does this happen? How can I keep the globals constant?
(Btw, Engine used is I Wanna Be The Engine V2)
Title: Re: Globals restarting?
Post by: Kyir on August 14, 2015, 06:25:01 PM
They're resetting because you're not actually saving the value of the variable. You need to fiddle with the save/load code for that, but I'm not sure how that engine structures it.
Title: Re: Globals restarting?
Post by: pieceofcheese87 on August 14, 2015, 07:04:05 PM
Why are you using such an old and outdated engine?
Title: Re: Globals restarting?
Post by: Derf on August 14, 2015, 07:36:20 PM
Whenever I restart my game, the globals restart, let's say item1 is at 1 when I restart/close it, and when I come back its again at 0, why does this happen? How can I keep the globals constant?
(Btw, Engine used is I Wanna Be The Engine V2)
The game restart function is essentially the same as the game closing then starting again, so that's why no variables are saved over. Your three options to fix this are:

1). Set every global variable to be saved and loaded in the save and load scripts of the engine.

2). Rework the game over system so that it restarts the room and not the game.

3). Use a different engine that handles things better (though I'm not sure which I'd suggest as every engine I've used I have inevitably had to recode the saving system as they are generally pretty terrible).
Title: Re: Globals restarting?
Post by: patrickgh3 on August 15, 2015, 03:47:29 PM
I said pretty much the same thing as Derf in this thread, which is essentially the same issue. https://www.iwannacommunity.com/forum/index.php?topic=1823.0 (https://www.iwannacommunity.com/forum/index.php?topic=1823.0)