Results 1 to 7 of 7

Thread: Can't get a simple "or" to work! And "or" is too short to search for on the forum.

Hybrid View

  1. #1

    [Solved] Can't get a simple "or" to work

    I've tried "a or b" and "a || b", and neither one works. The game always treats the "or" like an "and." I've got a very, very simple setup here so that there is no possibility of doubt:

    Condition: this
    On Act.: x1 = true

    Condition: this
    On Act.: x2 = true

    Condition: x1 or x2
    On Act.: player setdamage 1

    I've even got x1 and x2 set up with text cues, so I know that x1 is firing when it is meant to and x2 is firing when it is meant to. And yet I do not die if I only fire x1, or only fire x2. I only die when I fire both x1 and x2. Why is "or" being perceived by the game as an "and"?

    ---------- Post added at 21:21 ---------- Previous post was at 21:17 ----------

    Update: Hmm, I think I can work around this by simply creating a second trigger identical to the first except for the condition.

    Condition: x1
    On Act.: player setdamage 1

    Condition: x2
    On Act: player setdamage 1

    But then, what is the "or" function for? And I rather need it for a more complex script: (objtown2reached1 or !alive pla1 or !spawn1) and (objtown2reached2 or !alive pla2 or !spawn2) and (objtown2reached3 or !alive pla3 or !spawn3) and (objtown2reached4 or !alive pla4 or !spawn4)

    ---------- Post added at 22:33 ---------- Previous post was at 21:21 ----------

    Update: Solved. I worked around it by creating many triggers with one condition each, instead of one trigger with many conditions. Many conditions and few activations. The problem is solved, but since "or" and || are too small for the search engine, there doesn't seem to be much point in this thread remaining in existence.
    Last edited by Echo38; May 28 2012 at 02:31.

  2. #2
    Condition: x1 or x2
    On Act.: player setdamage 1


    It should work, I suspect you haven't declared both variables in which case even if one is true the trigger won't execute as it doesn't know what the other is.

    In an init or script make sure they're both set to either true or false.

    x1=true
    x2=true

  3. #3
    you should be able to use triggerActivated. Name each of your triggers, and in the third trigger place:

    Condition:triggerActivated nameOfFirstTrigger or triggerActivated nameOfSecondTrigger
    On Act.: player setdamage 1

  4. #4
    Use: x1 == true || x2 == true
    Otherwise you need to set x1 and x2 to false in init.sqf.

  5. #5
    Quote Originally Posted by MulleDK19 View Post
    Use: x1 == true || x2 == true
    You can't compare boolean variables in sqf against true of false. They are either true or false, so it is x1 || x2.

    Xeno

  6. #6
    Quote Originally Posted by Celery View Post
    Always initialize variables (x1 = false; etc. in init script) that you will be using later on, so that checking for them doesn't produce errors. That's the only thing you need to do to fix the problem.
    I always find it better to look if a variable exists, instead of checking if it's value is something (in same cases ofc, this is not an option), instead of initializing variables.
    But it can be very useful with such boolean checks as this one, f.e.:

    PHP Code:
    Conditionthis
    On Act
    .: x1 true

    Condition
    this
    On Act
    .: x2 true

    Condition
    : !isNil x1 } OR !isNil x2 }
    On Act.: player setdamage 1 
    Last edited by neokika; May 28 2012 at 11:33.
    Proud community admin/member of The Tour of Teamrespawn

  7. #7
    Always initialize variables (x1 = false; etc. in init script) that you will be using later on, so that checking for them doesn't produce errors. That's the only thing you need to do to fix the problem.

Similar Threads

  1. CfgVehicles: overriding "accuracy", "camuflage" and "sensitivity"
    By fabrizio_T in forum ARMA 2 & OA : ADDONS - Configs & Scripting
    Replies: 4
    Last Post: Apr 18 2013, 19:21
  2. List of "Armed Assault 1" addons that work in "ArmA II" as well
    By Dr. Horrible in forum ARMA 2 & OA - ADDONS & MODS: COMPLETE
    Replies: 168
    Last Post: Apr 17 2013, 06:58
  3. Does "name" movein(position) "vehiclename" not work anymore?
    By Pd3 in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 2
    Last Post: May 18 2012, 00:07
  4. Does the "Keys" folder stil "work"?
    By NoBrainer in forum ARMA 2 & OA - MULTIPLAYER
    Replies: 3
    Last Post: Oct 24 2009, 12:30
  5. Add "LAND", "Up" and "Down" actions to command menu
    By EricM in forum ARMA 2 & OA - SUGGESTIONS
    Replies: 4
    Last Post: Jul 4 2009, 19:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •