Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support


Thread Closed 
 
Thread Rating:
  • 2 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Advanced script widgets
Author Message
palistov Offline
Posting Freak

Posts: 1,214
Joined: Mar 2011
Reputation: 57
Post: #6
RE: Script widgets for new modders!

Quote:I might want to make a request about how to use local and global variables.

I'm used to using something like having an "int x = 0;" and then something happens causing int x to become 1 (x = 1; ) thus causing events to change because x = 1.

Ahh I see. Those indeed will serve your purpose, but only within the same function. If you set int x = 0, you will only be able to call "x" in that same function. Local variables, however, you can call anywhere within that same script.

So do SetLocalVarInt("var1", 0); and then you can do all kinds of stuff like

GetLocalVarInt("var1");
AddLocalVarInt("var1", x); //where x is any integer you choose

and combine those with if statements to give you more functionality.

Global variables work the same way, but you need to set up a global.hps file under your custom story's root. In that file you have to put

void OnGameStart()
{
    SetGlobalVarInt("gvar1", 0);

}

Then you can toy with those variables anywhere within the same custom story! Just use

GetGlobalVarInt("gvar1");
AddGlobalVarInt("gvar1", x); //where x is any integer

and also use if statements too! Smile

04-24-2011 02:52 AM
Find all posts by this user
Thread Closed 


Messages In This Thread
Advanced script widgets - palistov - 04-24-2011, 01:22 AM
RE: Script widgets for new modders! - Kyle - 04-24-2011, 02:11 AM
RE: Script widgets for new modders! - Kyle - 04-24-2011, 02:37 AM
RE: Script widgets for new modders! - palistov - 04-24-2011 02:52 AM
RE: Script widgets for new modders! - Kyle - 04-24-2011, 03:06 AM
RE: Advanced script widgets - laser50 - 04-24-2011, 09:27 AM
RE: Advanced script widgets - Kyle - 04-24-2011, 11:11 AM
RE: Advanced script widgets - teddifisk - 04-25-2011, 09:10 PM
RE: Advanced script widgets - palistov - 04-26-2011, 03:43 PM
RE: Advanced script widgets - Exostalker - 04-26-2011, 05:22 PM
RE: Advanced script widgets - Apjjm - 04-27-2011, 09:21 PM
RE: Advanced script widgets - palistov - 04-27-2011, 10:01 PM
RE: Advanced script widgets - Simpanra - 05-01-2011, 10:31 PM



User(s) browsing this thread: 1 Guest(s)