Frictional Games Forum (read-only)

Full Version: (ABANDONED)Need help with "if" functions...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okay, I KNOW I'm doing this wrong, but I need some pointers on the "if" function. Here's my script:
//_______________________________

void OnStart()
{
AddEntityCollideCallback("Player", "warnarea", "warn_func", false, 0);
}

void warn_func(string &in asParent, string &in asChild, int alState)
{
GetLocalVarString("jacket_1");
{
if(&in asEntity == true)
{
SetMessage("ScreenMessages", "warningmessage", 3);
}
if(&in asEntity == false)
{
SetMessage("ScreenMessages", "none", 1);
}
}
}

//__________________

The problem is what is in the parenthesis after the "if"s I don't know what I should title it. The thing I want it to do is when I walk into an area, if the "jacket_1" is active, the message from "if(&in asEntity == true)" tells me it needs to be gone. but if the jacket is inactive, the message does not display.
&in is only for parameters, not if statements. Also, asEntity doesn't exist.
(11-23-2011, 10:43 PM)Your Computer Wrote: [ -> ]&in is only for parameters, not if statements. Also, asEntity doesn't exist.
what should it be?
=[
No one knows what to put instead of "&in asEntity"? I'd really appreciate help as soon as possible... I need it for the 24-hour challenge.
First i have to go through what causes the body of an if statement to be executed. An if statement's purpose is to allow for conditions based on an expression. An if statement triggers when the expression (i.e. what is in the parentheses) evaluates to true. Since AngelScript tends to be picky with variables in the if expression, we have to rely on boolean operators. Boolean operators allow for the expression to return either true or false. However, variables that are already of type bool don't require these operators.

I have no idea what you're trying to do in your script, but it also seems like you don't fully understand how to set and get map variables. By now i would have expected you to understand at least script variables, but it doesn't look like your script illustrates competence in that area either. I think it would be easier if i just refer to you to one of my videos: Script basics. As for map variables, you should only consider setting them when you want them to be saved with the player's progress. Otherwise just stick to script variables.

To get the current value for a map variable you'd use the get functions, like GetLocalVarString, etc. Functions are capable of returning values. You're probably used to void, but the get functions for map variables return a value of the type included in the function name. Therefore when you call that function, you're supposed to store that value in a script variable. For example,
PHP Code:
string value GetLocalVarString("map_var_name"); 

As i said before, "&in" is not for if statements; though i should also add they're not for variable declarations either. When a variable does not exist, then you have to declare the variable before you can reference it any where else. The example i gave above is itself a declaration.
(11-24-2011, 01:51 AM)Your Computer Wrote: [ -> ]First i have to go through what causes the body of an if statement to be executed. An if statement's purpose is to allow for conditions based on an expression. An if statement triggers when the expression (i.e. what is in the parentheses) evaluates to true. Since AngelScript tends to be picky with variables in the if expression, we have to rely on boolean operators. Boolean operators allow for the expression to return either true or false. However, variables that are already of type bool don't require these operators.

I have no idea what you're trying to do in your script, but it also seems like you don't fully understand how to set and get map variables. By now i would have expected you to understand at least script variables, but it doesn't look like your script illustrates competence in that area either. I think it would be easier if i just refer to you to one of my videos: Script basics. As for map variables, you should only consider setting them when you want them to be saved with the player's progress. Otherwise just stick to script variables.

To get the current value for a map variable you'd use the get functions, like GetLocalVarString, etc. Functions are capable of returning values. You're probably used to void, but the get functions for map variables return a value of the type included in the function name. Therefore when you call that function, you're supposed to store that value in a script variable. For example,
PHP Code:
string value GetLocalVarString("map_var_name"); 

As i said before, "&in" is not for if statements; though i should also add they're not for variable declarations either. When a variable does not exist, then you have to declare the variable before you can reference it any where else. The example i gave above is itself a declaration.


I'm not the BEST, but I understand about half of the scripting process... "if" and "break" functions, I have yet to understand. (never had to use them until now) But I think I'm getting what you're saying. I'll experiment and see what I can come up with. Thanks a ton.

And I KNEW the variables I set were wrong, I was just putting in crap to see when something would come up, but I've been doing it wrong, so I've been at an impass. Again, this was my first time trying it and doing by way of "guess-and-check".


I don't know what to do... =\ It's too big of a jump for me right now. I'll just have the map run in another fashion. Thanks for the help though. I appreciate the time you took.