Frictional Games Forum (read-only)
(ABANDONED)Need help with "if" functions... - 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: (ABANDONED)Need help with "if" functions... (/thread-11474.html)



(ABANDONED)Need help with "if" functions... - Statyk - 11-23-2011

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.


RE: Need help with "if" functions... - Your Computer - 11-23-2011

&in is only for parameters, not if statements. Also, asEntity doesn't exist.


RE: Need help with "if" functions... - Statyk - 11-24-2011

(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?
=[



RE: Need help with "if" functions... - Statyk - 11-24-2011

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.



RE: Need help with "if" functions... - Your Computer - 11-24-2011

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.


RE: Need help with "if" functions... - Statyk - 11-24-2011

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