What are global variables? They are variables that are global, which means if you do something on one map, something on another one does something else.
EXAMPLE:
In map 1 you fixed a machinery. In map 3, a door will be lifted because the machinery is done.
END EXAMPLE.
Here's how you do it.
(NOTE: THE global.hps MUST BE IN YOUR MAPS/ DIRECTORY!)
1. Make a global.hps file (EXTENSION MUST BE .HPS!)
---
2. Type this on the global.hps
---
void OnGameStart()
{
SetGlobalVarInt("NAME", 0); //Change NAME to whatever you want the name to be.
}
Get it? This means that on Game Start (When the player plays the game first time. Not entering map first time)SetGlobalVarInt will set it's variable to 0.
---
3. In the map where the player must do something to do something else in another map, wrote this to the map's .hps file.
This must be in another function!
AddGlobalVarInt("NAME", 1); //Change NAME to whatever you want the name to be.
Get it? This means that if the Player does something, it will add the GlobalVarInt to 1.
---
4. In the map where you want something to do if the player has done something from another map, wrote this the the map's .hps file.
---
void OnEnter()
{
if(GetGlobalVarInt("NAME") == 1)
{
//Something changed if Player added the GlobalVarInt.
}
}
Get it? No? Fine. This means each time Player enters the map, the if-statement will check whether GlobalVarInt is 1 or not. If it's 1, it will do something. But if it didn't, it would do nothing.
Hope this helps. If there's another thread for this, i'm deeply sorry for not noticing it. It's directed for people who didn't knew Global Variables.
---
For Local Variables, change Global to Local on each function. Like GetGlobalVarInt to GetLocalVarInt. The only thing is that local variables do not use the global.hps. It must be within the map' hps file itself.
EDIT:
You can declare new global variables in the maps .hps file. Although using a global.hps saves room.
This was pointed out by Adrianis.