Frictional Games Forum (read-only)
Variables - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Variables (/thread-14152.html)



Variables - Shives - 03-21-2012

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)


RE: Variables - palistov - 03-21-2012

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


RE: Variables - Shives - 03-21-2012

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


RE: Variables - ClayPigeon - 03-21-2012

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.




RE: Variables - Shives - 03-21-2012

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