Frictional Games Forum (read-only)

Full Version: Local Variables - problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I dont get it. What's the problem Sad. How can I use steps actually in there? It gives me error that for example in if statement, I cant use string and int, even tho int is stored inside the string :/.

void stepadder(string &in asTimer)
{
GetLocalVarInt("steps");
if("steps" < 24)
{
AddLocalVarInt("steps", 1);
AddTimer("", 1, "stepadder");
AddTimer("", 0, "stepeffect");
}
else
{
//finish stepping
}
}

void stepeffect(string &in asTimer)
{
GetLocalVarInt("steps");
CreateParticleSystemAtEntity("step" + "steps", "ps_guardian_appear_explosion.ps", "ScriptArea_" + "steps" ,false);
}

Ok, never mind Smile. I changed "steps" with GetLocalVarInt("steps") and it solved my problem!

I didn't do proper research Smile!

Sad part it really doesn't still work as I want, but I'll get it to work! Got it to work Wink
Erg, only if you still had the problem so then I could explain it more proper. xD
I don't mind if you explain it properly. But I think I got it. My scripts are working all perfectly with no problem. Basically local works on one map, global works on all maps. Some kind of text, value or whatever thing, right Smile?
(08-22-2011, 02:58 PM)Elven Wrote: [ -> ]I don't mind if you explain it properly. But I think I got it. My scripts are working all perfectly with no problem. Basically local works on one map, global works on all maps. Some kind of text, value or whatever thing, right Smile?

GetLocalVar<Type>() doesn't magically create a local function variable for you to use. You're supposed to store or use the return value of the function yourself.

For example:
Code:
string value = GetLocalVarString("steps");
if (value == "something")
     // do something...

// Or...
int value = GetLocalVarInt("steps");
if (value == 1)
     // do something...

// Or...
if (GetLocalVarInt("steps") == 1)
     // do something...

These functions are for the game to store in a save file (i.e. when the user or game saves). If you don't need these values to be saved by the game in a save file, then you can use normal variables.
Thx, figured it out already Smile. But for others who have same problem Smile