How do I reset global variables in ONLY ONE SHEET?

0 favourites
  • 4 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.
  • Hey guys my game is about 90 % done. Core gameplay is good, I learned how to create high scores and even have separate Webstorage variables for number of this sprite destroyed, number of times this powerup was used...

    I was reading the manual recently and only recently learned the concept of LOCAL VARIABLES. Having read only the parts I thought I needed, I wrongfully assumed that all global variables in one event sheet were "local to that event sheet." Now since my game is an endless wave destroyer type, most of my variables are used as Booleans for (is the game paused? Is my character currently 'dead'? Is the starting countdown over? ) and holders of information such as sprites destroyed for the current round. I tried to "localize" everything by creating a group and dragging every event and variable in there and when I pressed F5, the results were disastrous.

    My current sticking point is that I'm trying to create a separate layout that holds badges and medals for achievements and those have global variables as well that compare variables such as "Number_of_Powerups_Used_When_The_Game_Was_Lauched" to "PowerUps_Used_This_Round." and as you can probably tell, using the "System: Reset Global Variables" also resets the quantity in a separate layout to 0.

    I know it's my fault for not reading the manual but is there a way I could reset only my choice variables WITHOUT having to create an action for each? I think my next best option is to create a BOOLEAN that goes: "Reset_This_Event_Sheets_Variables = 1" but I don't want to have to do that if it isn't necessary.

    Thank you!!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey Mp.

    The short answer is no. Create a function called "Reset" that when called switches the global variables you need to the default setting (you could use another global variable instead of a function to trigger this but you should do yourself a favour and get used to using functions instead imo).

  • You know ive wonder how come there isnt something like a drop down style in the event or an add to list of reset global variable similar to the Family creation. That would help a bunch in controlling the game if it depend on certain variable to turn on events that is repeatable n such. And like he said to keep achievement and to reset main game global.

  • Hey guys. Late reply but thanks so much for suggesting functions.

    I've since then turned a lot of my code into functions and they work like a charm.

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