Putting two "if"s together - 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: Putting two "if"s together (/thread-16764.html) Pages:
1
2
|
Putting two "if"s together - ApeCake - 07-05-2012 I do not really need this for my custom story, but I am just incredibly curious about this. The question is; how do you make something happen when two (or three, or four, whatever) things are set "true". Example; I want a message to display when my door is locked and when my doors health is lower than 70. This is what I wrote, mostly looking at another cs, but then failing horribly. I'm think the concept looks like this though, the only part that this is completely wrong. void mansion_1(string &in entity) { if(GetSwingDoorLocked("mansion_1" && GetPropHealth("mansion_1") == i<70)) { SetMessage("Messages", "labdoorlocked", 0); } } (mansion_1 is the name of the PlayerInteractCallback of the door, and the actual name of the door.) This above was just me kinda messing around and trying to figure it out. I couldn't get it complete though. And as far as I'm aware there isn't a solution on the wiki. Any help would be appreciated. RE: Putting two "if"s together - Obliviator27 - 07-05-2012 Basically, you'd want if(GetSwingDoorLocked("mansion_1") == false && GetPropHealth("mansion_1") < 70) I do believe. Edit: Apjjm responded at the same time. Bah. Anyhow, they're the same script, his is just neater. RE: Putting two "if"s together - Apjjm - 07-05-2012 You were not far off at all: Code: void mansion_1(string &in entity) RE: Putting two - SilentStriker - 07-05-2012 Nevermind RE: Putting two "if"s together - himynamebob1 - 07-05-2012 Would this work? void mansion_1(string &in entity) { if(GetSwingDoorLocked("mansion_1") == 1(orwhatevertrueis) { if(GetPropHealth("mansion_1") == i<70) { SetMessage("Messages", "labdoorlocked", 0); } } } RE: Putting two "if"s together - Your Computer - 07-05-2012 (07-05-2012, 09:40 PM)himynamebob1 Wrote: Would this work? No. RE: Putting two "if"s together - ApeCake - 07-05-2012 Thanks guys! I'll try it tomorrow. Thanks for the help! Reps for all! RE: Putting two "if"s together - ApeCake - 07-09-2012 Okay, I hate to bump this thread, but I want something to activate when I pulled a lever and when the door is closed (it's an elevator, you see.) How would I work this out? Something like this? void elevatorgo(string &in asEntity, int alState) { if ((alState == -1) && GetSwingDoorClosed("leftelevatordoor") == true) { AddTimer("EG1", 1.5, "elevatorgoes"); PlaySoundAtEntity("", "quest_completed.snt", "Player", 0, false); PlayGuiSound("move_gate.snt", 2); } } The door is called "leftelevatordoor". It worked without the GetSwingDoorClosed, so the problem is definitely in that part. Thanks in advance. RE: Putting two "if"s together - Cruzore - 07-09-2012 try this instead: if (alState == -1 && GetSwingDoorClosed("leftelevatordoor") == true) RE: Putting two "if"s together - Apjjm - 07-09-2012 Tip for dealing with boolean expressions: It's worth noting that putting "==true" is redundant - because "x==true" will just evaluate to either "true" or "false" anyway. This is like stating "if saying the door is open is true", when you would normally say "if the door is open". Likewise for using "==false", you can just use the logical not opeator "!" - e.g. "!x" is the same as "x==false". Doing this stops a redudant equality check (which hopefully the interpreter optimises out - but it might not), and also makes the code easier to read - it's much easier to read: "if the door is not open" vs "saying the door is open is false" |