how to say x OR x?

Fodder76Fodder76 Member Posts: 154
edited November -1 in Working with GS (Mac)
I'm sure this is programming 101, but I'm just not able to get it to work.

I need an expression that allows me to say if x is equal to x OR x.

The or is what I'm having trouble with. My programmer friend is telling me that the standard format for or is ||, but I can't seem to get that to work.

Help?

Comments

  • RattleheadRattlehead Member Posts: 485
    It is definitely dependent on the programming language being used; there are a ton of variations on that theme...

    But thankfully with GameSalad you don't have to worry about any scripting whatsoever. You can achieve the same effect by staking the Rule behaviour.

    Drag a Rule behaviour into your actor and for the first condition of your OR statement, leave it as "When All conditions are valid" and then set it to an Attribute matching one of your variables; most probable will be that this is a Game variable but it could be a local variable as well.

    Then, if it is a simple "if this or else" type of statement, then you can put the equivalent of the false part of the condition (where the first part fails) into the Otherwise part of the rule.

    If it is a multi-part conditional test (3 or more tests), you can drag more Rule behaviours into the Otherwise section. Just be careful that you walk through all the potential conditions that could be executed.

    Good luck.
  • quantumsheepquantumsheep Member Posts: 8,188
    You could also just click the 'all' condition in the top left of a rule. This will change it to 'any'.

    Then you can put in 'When x = 30'
    and
    'when x = 40'

    And when either of those conditions are satisfied, the rule will kick off.

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • Fodder76Fodder76 Member Posts: 154
    Rattlehead. Well, I need the otherwise for a different outcome, so I can't use that. Your second option is something I attempted, but I wasn't able to get it to work. Perhaps I had some other error. I'll check into it. But even so, it seems like there should be a more efficient way of doing this than having a long chain of rules. I'm just trying to be efficient.

    Quantum. I would love to go that route, but unfortunately I also need to check for a touch, so I can't use the 'any' option, as it will always be triggered.

    Thanks for your responses!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    QS is correct. "Any" represents OR in GameSalad.

    You can also nest Rules inside of other Rules to make more complex behaviors, which is what you'll want to do.

    Your structure will look something like this:

    Rule
    When ALL conditions are valid
    Touch is Pressed
    .....Rule
    .....When ANY conditions are valid
    .....condition 1
    .....condition 2
    ..........do something
    .....otherwise
    ..........do something else
  • diegocsdiegocs Member Posts: 531
    but if i want to do something like change attribute to 1 or 4
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Ah, if you want to set an attribute like that, it's a little more complicated with GameSalad, but can certainly be done.

    It depends how you want to do it...do you want to randomly set it?

    i.e: When this actor is touched, randomly set the attribute to either 1 or 4?
  • Fodder76Fodder76 Member Posts: 154
    Ahh thanks very much FireMaple. That looks like it will work for what I need to do. Looks like I'm tending to over think things a bit.

    Thanks to everyone! Can't wait to give it a shot in the morning.
Sign In or Register to comment.