Frictional Games Forum (read-only)
Anything wrong with this if-statement? - 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: Anything wrong with this if-statement? (/thread-14309.html)



Anything wrong with this if-statement? - maggigyo - 03-28-2012


Can someone please tell me if there is something wrong with this if-statement?

if(GetLocalVarInt("gamestate")==6)


I have used the ProgLog to make sure exactly where the problem lies.
This statement is inside my own function, but the function itself works.
The gamestate variable has the value 6 at this point as well.
The problem definately is the if-statement.


I have some programming experience with C++. However, I don't know what differences there are when using AngelScript. This leads to a lot of guessing like "maybe I should do something different that I don't know of".



RE: Anything wrong with this if-statement? - SilentStriker - 03-28-2012

It doesn't look wrong.



RE: Anything wrong with this if-statement? - palistov - 03-28-2012

Like Silent said, your if statement is syntactically correct. Shouldn't be an issue there. What statement(s) follow your if statement? Also, where is this if statement? If I recall correctly, if statements enclosed in for-loops or switch-case structures can cause issues. Maybe it's vice versa. But anyways my experience just tells me to avoid that kind of control flow, especially if your if statement is using braces to enclose more than one expression.

And do the statements enclosed following your if statement fail to execute? Also, try adding a debug message to show you the value of the local variable "gamestate". To concatenate, just use the + operator between the string and GetLocalVarInt("gamestate"). It's one of the rare few implicit conversions we are allowed to do without the compiler throwing a fit.

By the way. What does ProgLog do? I've NEVER used it and the documentation on it is skint. I usually use Print or AddDebugMessage Smile