Feature Request, Cannot Reset Global Variable Tick Box

0 favourites
  • 8 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Ashley

    Hey Ashley, could you add a tick box "Cannot Reset" next to the "Static" and "Constant" tick boxes?

    Some games use global variables to store if the player is dead or not, but need to reset everything else when the player dies.

    Currently it's set up so that you have to make a function to reset every global variable except for the one you don't want reset.

  • Nesteris

    What about using webstorage to store those values?

    https://www.scirra.com/manual/120/webstorage

  • TiAm

    [quote:3qzuv87d]However if the user opts to clear all their cookies or offline website data, WebStorage will be cleared.

    I don't know, it'd be pretty silly if the user cleared their WebStorage and found that they broke the game.

    Using global variables the way I set it up now is perfect, if the player dies he can respawn, if I exit game completely and open it up again the player doesn't double spawn. (If the global variable has the value "Dead", then upon New Game, a new player is created. So value got saved between closing and opening the game again, it would break.)

    Could I set it up the same way using WebStorage or Dictionary Key? Using Session Storage with WebStorage seems promising, but I wish I didn't have to change it.

    Could I use a Dictionary Key / WebStorage to get the same functionality I have with Global Variables ?

  • TiAm

    [quote:1ywh6a8o]However if the user opts to clear all their cookies or offline website data, WebStorage will be cleared.

    I don't know, it'd be pretty silly if the user cleared their WebStorage and found that they broke the game.

    The player is highly unlikely to clear webstorage in the middle of playing your game. The advantage of webstorage is persistance between play sessions, good for high scores, level progress, that sort of thing.

    However, it seems like the variables you are talking about would only be relevant during runtime. In that case, your best bet would be a global dictionary; it's contents won't be cleared when clearing global variables.

  • [quote:33io9lr5]However, it seems like the variables you are talking about would only be relevant during runtime. In that case, your best bet would be a global dictionary; it's contents won't be cleared when clearing global variables.

    Meaning that they reset to "default" when you exit the application/.exe?

    I can use keys in the same way I use Global Variables, right? I can change the value for a key and set up the conditions as if I was using global variables, could I get confirmation of that?

    Thanks a lot for the help, this past month development has been booming so fast I can barely keep up and I'm the developer!

  • [quote:3t92dz4l]However, it seems like the variables you are talking about would only be relevant during runtime. In that case, your best bet would be a global dictionary; it's contents won't be cleared when clearing global variables.

    Meaning that they reset to "default" when you exit the application/.exe?

    I can use keys in the same way I use Global Variables, right? I can change the value for a key and set up the conditions as if I was using global variables, could I get confirmation of that?

    Yes. You still have to initialize the dictionary, which you can do in a subgroup/function/etc. Here's an example capx:

  • Do I really have to go through all those events that include Global Variables to replicate the usage of a single global variable?

    Since we're using Global Dictionary, I can't just make a key "PlayerStatus" with a value "Alive", and set it to "Dead" when the player is destroyed so the game knows to create a new player when the new game layout starts? I think you might be making it needlessly complicated.

    Could I set it up like this? It seems a lot simpler this way.

    [attachment=0:1rsd97da][/attachment:1rsd97da]

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I got the same result by using a Global Dictionary with a Boolean Instance Variable, thanks for the help TiAm !

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)