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
[SIMPLE] Variables
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#1
[SIMPLE] Variables

Ok, so I'm having a little trouble with some variable-scripts, that I haven't tried before. It looks like this:

void WoodCreakStart(string &in asParent, string &in asChild, int alState)
{
AddTimer("WoodCreakStart", 5, "WoodCreak");
}

void WoodCreak(string &in asTimer)
{
if(asTimer == "WoodCreakStart")
{
StartScreenShake(0.03f, 5.0f, 2.0f, 2.0f);
PlaySoundAtEntity("Creak", "00_creak.snt", "Player", 2.0f, false);
AddTimer("Creak_1", 0.5f, "WoodCreak");
}

if(asTimer == "Creak_1")
{
if(GetLocalVarInt("CreakVar") < 7)
{
CreateParticleSystemAtEntity("CreakDust_"+CreakVar, "ps_dust_drilling.ps", "WoodCreakParticle_"+CreakVar, false);
AddLocalVarInt("CreakVar", 1);
AddTimer("Creak_1", 0.1f, "WoodCreak");
}
}
}

Simply, what happens is that when I enter the area, dust should be drilling from each 6 areas once.
But it should happen like this:
Dust from area1
Wait 0.1 seconds
Dust from area2
Wait 0.1 seconds

and so on

This is where i have the trouble:

if(asTimer == "Creak_1")
{
if(GetLocalVarInt("CreakVar") < 7)
{
CreateParticleSystemAtEntity("CreakDust_"+CreakVar, "ps_dust_drilling.ps", "WoodCreakParticle_"+CreakVar, false);
AddLocalVarInt("CreakVar", 1);
AddTimer("Creak_1", 0.1f, "WoodCreak");
}
}

It says CreakVar is not declared... but should it be, when i use it like +CreakVar?

Trying is the first step to success.
(This post was last modified: 03-12-2013, 05:17 PM by FlawlessHappiness.)
03-12-2013, 04:30 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#2
RE: [SIMPLE] Variables

You might have to use 'SetLocalVarInt' first to declare the var. Then AddLocal..etc just adds to the value
Though, I haven't tried only using AddLocal...etc so apologies if I'm wrong on that

More importantly, when using a variable set using the functions (SetLocal...etc), you can't use the variable just by using the name as you tried here, CreateParticleSystemAtEntity("CreakDust_"+CreakVar
You need to use the function GetLocalVar...etc in order to get the value - that goes for checking the value as well (in an if statement, for example)

To make things easier (so you can use the shorthand method like you tried), you can make a line like so,

int inCreakVar = GetLocalVarInt("CreakVar");

That way you assign the value from the function-declared variable into a local variable, then you can do CreateParticleSystemAtEntity("CreakDust_"+inCreakVar

(called it 'inCreakVar' to make it distinct from CreakVar, though you can use the same name as they are declared in a different way (theres more to the way variables work, but thats another topic for another time))

Hope that helps, let me know if you want more explanation

(This post was last modified: 03-12-2013, 05:17 PM by Adrianis.)
03-12-2013, 05:07 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#3
RE: [SIMPLE] Variables

Helps ALOT! Smile Thank you!

That was the problem! I didn't know how to assign an interger to a variable. THanks!

Trying is the first step to success.
03-12-2013, 05:17 PM
Find




Users browsing this thread: 1 Guest(s)