Frictional Games Forum (read-only)
Double if(GetEntitiesCollide - Problem [SOLVED] - 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: Double if(GetEntitiesCollide - Problem [SOLVED] (/thread-16940.html)



Double if(GetEntitiesCollide - Problem [SOLVED] - FlawlessHappiness - 07-13-2012

Hello smart people ^^

I have a problem with my if-statement.
The error is: Expected exrpession value.

My script is:


void OnCollide_3(string &in asParent, string &in asChild, int alState)
{
if(GetEntitiesCollide("stone_med01_brown_1", "ScriptArea_2") == true) && if(GetEntitiesCollide("stone_med01_brown_2", "ScriptArea_2") == true) <-- Points to this line
{
FadeOut(0);
PlaySoundAtEntity("", "explosion_rock_large", "Player", 0.5f, false);
}
}

But what is wrong.. I can't seem to figure it out myself..


RE: Double if(GetEntitiesCollide - Problem - Omyn - 07-13-2012

(07-13-2012, 04:32 PM)beecake Wrote: Hello smart people ^^

I have a problem with my if-statement.
The error is: Expected exrpession value.

My script is:


void OnCollide_3(string &in asParent, string &in asChild, int alState)
{
if(GetEntitiesCollide("stone_med01_brown_1", "ScriptArea_2") == true) && if(GetEntitiesCollide("stone_med01_brown_2", "ScriptArea_2") == true) <-- Points to this line
{
FadeOut(0);
PlaySoundAtEntity("", "explosion_rock_large", "Player", 0.5f, false);
}
}

But what is wrong.. I can't seem to figure it out myself..
I'm no expert in c++ but i think for a multiple condition if statement, you only need one "if" then enclose both conditions wothin the parenthesis seperated by the &&.


RE: Double if(GetEntitiesCollide - Problem - FlawlessHappiness - 07-13-2012

You are probably right, but the error is still there


RE: Double if(GetEntitiesCollide - Problem - Your Computer - 07-13-2012

(07-13-2012, 06:55 PM)beecake Wrote: You are probably right, but the error is still there

Omyn is correct. If statements don't return values, so using the logical AND operator on two if statements won't work. You're supposed to place the condition within the if statement's parenthesis. The condition being the statements that can evaluate to either true or false.

PHP Code:
if(GetEntitiesCollide("stone_med01_brown_1""ScriptArea_2") == true
&& GetEntitiesCollide("stone_med01_brown_2""ScriptArea_2") == true



RE: Double if(GetEntitiesCollide - Problem - Adny - 07-13-2012

Here's an example of the double if statement that Frictional Games used for the book puzzle in the archives (it's actually 3, but I removed the last one so you can compare it to yours easier). It's all one line, each part is separated by "(space)&&(space)", and the second part doesn't have the extra pair of parentheses ().
if(GetLocalVarInt("VarSecretBook_1") == 1 && GetLocalVarInt("VarSecretBook_2") == 1

Hope that helped.


RE: Double if(GetEntitiesCollide - Problem - FlawlessHappiness - 07-13-2012

YYYYES i understand it now! And it also works ^_^ You guys are so brilliant Big Grin