Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: rmonic79 on Fri 14/07/2017 00:45:36

Title: Global variable counter on restore event [SOLVED]
Post by: rmonic79 on Fri 14/07/2017 00:45:36
guys i had no problem to set a variable with an if on  if (event == eEventRestoreGame)
now i'm tryng to make a counter on single restore event to unlock an easy mode after certain amounts of deaths but it go back to previous value.
any suggestions? (it works storing the value in a file but i would like to know if there's a better solution.)
Title: Re: Global variable counter on restore event
Post by: Gurok on Fri 14/07/2017 02:17:11
Each time you restore a game, the counter is being reset because it's part of the saved game data.

Using an external file is a perfectly workable solution. I would keep track of how many times each slot has been restored and reset a slot's restore count when that slot is saved.

Thinking outside the box, you could implement your own "retry" button when the player dies. Have that button move the player to the start of the scene and reset any variables, then increment a retry counter. It would mean custom scripting for each death in the game, but as you're not restoring, you'll avoid the pitfalls of your current approach.
Title: Re: Global variable counter on restore event
Post by: rmonic79 on Fri 14/07/2017 05:39:38
Thanks gurok i think i'll go with file cause reset this specific room is below the time i have but it could be useful in other context.
By the way the now that i think of it, code works one time, so maybe it's possible that if i make an autosave after each restore it could works.
Title: Re: Global variable counter on restore event
Post by: rmonic79 on Fri 14/07/2017 10:50:12
Solved with file! :)