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
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


Messages In This Thread
Variables - by Shives - 03-21-2012, 04:07 PM
RE: Variables - by palistov - 03-21-2012, 04:12 PM
RE: Variables - by Shives - 03-21-2012, 06:41 PM
RE: Variables - by ClayPigeon - 03-21-2012, 07:50 PM
RE: Variables - by Shives - 03-21-2012, 08:50 PM



Users browsing this thread: 1 Guest(s)