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
(ABANDONED)Need help with "if" functions...
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#1
(ABANDONED)Need help with "if" functions...

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.
(This post was last modified: 11-24-2011, 03:32 AM by Statyk.)
11-23-2011, 10:20 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Need help with "if" functions...

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

Tutorials: From Noob to Pro
(This post was last modified: 11-23-2011, 10:45 PM by Your Computer.)
11-23-2011, 10:43 PM
Website Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#3
RE: Need help with "if" functions...

(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?
=[
11-24-2011, 12:00 AM
Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#4
RE: Need help with "if" functions...

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.
11-24-2011, 01:45 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#5
RE: Need help with "if" functions...

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: (Select All)
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.

Tutorials: From Noob to Pro
(This post was last modified: 11-24-2011, 01:51 AM by Your Computer.)
11-24-2011, 01:51 AM
Website Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#6
RE: Need help with "if" functions...

(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: (Select All)
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.
(This post was last modified: 11-24-2011, 03:02 AM by Statyk.)
11-24-2011, 02:17 AM
Find




Users browsing this thread: 2 Guest(s)