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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variables
Shives Offline
Member

Posts: 154
Threads: 41
Joined: Jan 2012
Reputation: 1
#1
Variables

Hi
I need a fast and short tutorial about Variables.
Because I don't know what the variables are for. Big Grin
But I need to know it
I've already seen the tutorial on the Wiki.
But I don't really get it. (Because my english isn't good)

My Custom Story
http://www.frictionalgames.com/forum/thread-12587.html

Sorry for bad English


03-21-2012, 04:07 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#2
RE: Variables

Variables are a way to store information. Then, later, you can use that information to assert what will happen in-game via script.

03-21-2012, 04:12 PM
Find
Shives Offline
Member

Posts: 154
Threads: 41
Joined: Jan 2012
Reputation: 1
#3
RE: Variables

What do you mean with informations?
Could you make an example please?

My Custom Story
http://www.frictionalgames.com/forum/thread-12587.html

Sorry for bad English


03-21-2012, 06:41 PM
Find
ClayPigeon Offline
Member

Posts: 214
Threads: 13
Joined: Mar 2012
Reputation: 8
#4
RE: Variables

Okay let's make an example.
First of all we will make a local variable called "EX".
The variable's default value, that is set by us at first will be 0, and then, after the player enters an area called "AREA", the function "FUNC" will be called, and the variable will be changed to any other value.

void OnEnter()
{
SetLocalVarInt("EX", 0); // 0 is the value we're giving to the var at first.
AddEntityCollideCallback("Player", "AREA", "FUNC", true, 1); //The area
}

Now we want to change the value of the variable if something happens, and then check it's value to do other things, example:

void FUNC(string &in asEntity, int alState)
{
AddLocalVarInt("EX", 1); //Adding '1' to the variable's value.
}


Now we want to check the variable's value, and do something if it equals 1, else we'll do something else.


void AnyOtherFunctionYouHave()
{
if(GetLocalVarInt("EX") == 1)
{
GiveSanityDamage(1.0f, true);
}
else
{
GiveSanityDamage(1.5f, true);
}
}


Okay, so what we did is, we've set an area in which the player will enter to, will set the variables "EX" value to '1' and then we checked in AnyOtherFunctionYouHave the variable's value, if it equals 1, the player will get 1 damage of sanity, else he will get 1.5 damage of sanity.

03-21-2012, 07:50 PM
Find
Shives Offline
Member

Posts: 154
Threads: 41
Joined: Jan 2012
Reputation: 1
#5
RE: Variables

Thank you
O thinl I get it I'll test it soon

My Custom Story
http://www.frictionalgames.com/forum/thread-12587.html

Sorry for bad English


03-21-2012, 08:50 PM
Find




Users browsing this thread: 1 Guest(s)