Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 5 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looking For Help? Look No More!
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#18
RE: Looking For Help? Look No More!

(08-29-2011, 05:18 PM)rybray Wrote: I would like to know how global variables work, the Wiki didn't help me very much and there dont seem to be good youtube tutorials (id love to make one...if i understood how they worked).

Global variables: what are they, how do they work? What functions do they have in a custom story?

Global variables are like any other variable, but more like a local variable. Wink

Normal Variable: int x = 5;
Local Variable: SetLocalVarInt("x", 5);
Global Variable: SetGlobalVarInt("x", 5);

Global variables are used in a custom story to "connect" all the maps together in a sense. Lets say you pick a path between two on a map called "Map01". The path you pick leads you back to the same track you were on where these two paths join up again. If you played Gears of War, then you'll know what I'm talking about. But let's say the path you choose alters later gameplay. Lets say there's a monster boss at the end of the game. If you choose "Path01", then you have found the monster's weakness, else if you chose "Path02", then you didn't do what you did when going to "Path01". But the boss is in "Map02", the second map.

The computer needs to transfer the data of the choice you made in "Map01" to "Map02" where you fight the boss. This is why there are global variables so that data can be altered throughout multiple maps in a custom story without worrying about the connection between all of them.

To set up global variables, you need to make sure that you make a file in your custom story's "maps" folder called "global.hps". Where the ending extension is ".hps" and isn't part of the actual name. In there, you can set a global variable up like this:

void OnGameStart()
{
     SetGlobalVarInt("Global01", 0);
}

Then you can access this data in whatever script files for your maps are, which should be in the same folder with this "global.hps". You can use "AddGlobalVarInt("Global01", 1);" to chance the value of it much like the way local variables work.

I hope this helps you, and if you have any questions, ask away! Smile

08-29-2011, 05:54 PM
Find


Messages In This Thread
Looking For Help? Look No More! - by Kyle - 08-28-2011, 03:35 PM
RE: Looking For Help? Look No More! - by Kyle - 08-28-2011, 03:51 PM
RE: Looking For Help? Look No More! - by Kyle - 08-28-2011, 04:19 PM
RE: Looking For Help? Look No More! - by Elven - 08-28-2011, 07:42 PM
RE: Looking For Help? Look No More! - by Elven - 08-28-2011, 08:21 PM
RE: Looking For Help? Look No More! - by Legato - 08-28-2011, 10:42 PM
RE: Looking For Help? Look No More! - by Legato - 08-29-2011, 12:54 AM
RE: Looking For Help? Look No More! - by Kyle - 08-29-2011, 12:51 PM
RE: Looking For Help? Look No More! - by rybray - 08-29-2011, 05:18 PM
RE: Looking For Help? Look No More! - by Kyle - 08-29-2011, 05:54 PM
RE: Looking For Help? Look No More! - by rybray - 08-29-2011, 06:11 PM
RE: Looking For Help? Look No More! - by Kyle - 08-29-2011, 06:19 PM
RE: Looking For Help? Look No More! - by Kyle - 08-29-2011, 06:33 PM
RE: Looking For Help? Look No More! - by ZRPT - 08-29-2011, 06:41 PM
RE: Looking For Help? Look No More! - by Kyle - 08-29-2011, 07:33 PM
RE: Looking For Help? Look No More! - by Kyle - 08-29-2011, 08:29 PM
RE: Looking For Help? Look No More! - by zeravia - 08-29-2011, 09:15 PM
RE: Looking For Help? Look No More! - by DRedshot - 08-30-2011, 12:42 PM
RE: Looking For Help? Look No More! - by Kyle - 08-30-2011, 12:47 PM
RE: Looking For Help? Look No More! - by DRedshot - 08-30-2011, 12:59 PM
RE: Looking For Help? Look No More! - by Elven - 08-30-2011, 02:46 PM
RE: Looking For Help? Look No More! - by Kyle - 08-30-2011, 03:43 PM
RE: Looking For Help? Look No More! - by Elven - 08-30-2011, 03:45 PM
RE: Looking For Help? Look No More! - by Kyle - 08-30-2011, 04:22 PM
RE: Looking For Help? Look No More! - by Elven - 08-30-2011, 04:38 PM
RE: Looking For Help? Look No More! - by ZRPT1 - 08-30-2011, 05:23 PM
RE: Looking For Help? Look No More! - by Kyle - 08-30-2011, 05:31 PM
RE: Looking For Help? Look No More! - by ZRPT1 - 08-30-2011, 05:34 PM
RE: Looking For Help? Look No More! - by Kyle - 08-30-2011, 06:14 PM
RE: Looking For Help? Look No More! - by ZRPT1 - 08-30-2011, 06:24 PM
RE: Looking For Help? Look No More! - by Kyle - 08-31-2011, 03:13 AM
RE: Looking For Help? Look No More! - by xiphirx - 08-31-2011, 03:46 AM
RE: Looking For Help? Look No More! - by xiphirx - 08-31-2011, 04:06 AM
RE: Looking For Help? Look No More! - by xiphirx - 08-31-2011, 05:04 AM
RE: Looking For Help? Look No More! - by DRedshot - 08-31-2011, 11:58 AM
RE: Looking For Help? Look No More! - by TheBaker - 09-01-2011, 06:39 PM
RE: Looking For Help? Look No More! - by rybray - 09-03-2011, 03:01 PM
RE: Looking For Help? Look No More! - by Selyp - 09-04-2011, 12:45 AM
RE: Looking For Help? Look No More! - by rybray - 09-04-2011, 06:07 PM
RE: Looking For Help? Look No More! - by Kyle - 09-05-2011, 12:45 PM
RE: Looking For Help? Look No More! - by Kyle - 09-05-2011, 07:04 PM
RE: Looking For Help? Look No More! - by xiphirx - 09-06-2011, 03:28 AM
RE: Looking For Help? Look No More! - by JMFStorm - 09-07-2011, 05:23 AM
RE: Looking For Help? Look No More! - by DRedshot - 09-15-2011, 03:12 PM
RE: Looking For Help? Look No More! - by DRedshot - 09-16-2011, 10:51 AM
RE: Looking For Help? Look No More! - by Bearscar - 09-16-2011, 10:57 AM
RE: Looking For Help? Look No More! - by Kyle - 09-16-2011, 11:05 AM
RE: Looking For Help? Look No More! - by Bearscar - 09-16-2011, 11:24 AM
RE: Looking For Help? Look No More! - by Leu Radu - 09-16-2011, 09:22 PM
RE: Looking For Help? Look No More! - by Dilzilla - 09-16-2011, 11:56 PM
RE: Looking For Help? Look No More! - by Kman - 09-17-2011, 05:49 AM
RE: Looking For Help? Look No More! - by Elven - 09-17-2011, 09:35 PM
RE: Looking For Help? Look No More! - by Elven - 09-17-2011, 11:50 PM



Users browsing this thread: 6 Guest(s)