[Variable] = [value] "this" OR [value] "that"

0 favourites
  • 9 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I want to check in a single Event condition if a text/string variable has either of two possible values. In a similar way that you can set a value like "This text " & "this text " & "will be set to a variable.", where the & serves as a kind of "link" (I don't know the tech geek term) to all the values wanting to be equally stored to the variable.

    However, what if I want to check if EITHER of the values are already in the variable?

    Similar to how we can make an Event block an OR block, is there a cousin to the & that functions as a sort of Boolean for a single variable test comparison (condition)?

    + System | Variable = "This" OR "That"

    So the condition would be satisfied if either "This" or "That" was the Variable value. If such an option exists, what symbol do I use?

  • Maybe this will help You.

    http://www.scirra.com/forum/topic66617.html

  • You can emulate a logical OR with a function. As pictured here.

    <img src="http://www.freewebs.com/johnwof/or.PNG" border="0" />

    A simple reversal of the logic could also emulate a logical AND... but it's quite useless considering Construct already does that ! <img src="smileys/smiley17.gif" border="0" align="middle" />

    edit: Oh, I almost forgot... just call this function in a condition like so : System -> Compare two value

    1st value = Function.Call("OR", statement1, statement2...)

    2nd value = 1

  • shinkan - Yup! That'll work! Thank you, sir!

    Magistross - That...kinda makes sense. I am not yet versed in using the Function events, so I'm going to have to study up on those. But from the looks of things, it may make my condition checking a lot more refined. Thank you, too! I'll check into it.

  • Here's a simple yet working example to help you understand how it could work.

  • Magistross - Thank you, sir! I'll check it out later on (gots me a job interview to prepare for :) ).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can emulate a logical OR with a function. As pictured here.

    <img src="http://www.freewebs.com/johnwof/or.PNG" border="0" />

    A simple reversal of the logic could also emulate a logical AND... but it's quite useless considering Construct already does that ! <img src="smileys/smiley17.gif" border="0" align="middle" />

    edit: Oh, I almost forgot... just call this function in a condition like so : System -> Compare two value

    1st value = Function.Call("OR", statement1, statement2...)

    2nd value = 1

    it's very useful for working on sitelock, thanks Magistross!

  • Could you use the or operator for this?

    So in your case this would become:

    System compare two values: Variable="This" | Variable="That" = 1

  • Or Operator html example

    (use left and right arrow keys to change the number)

    Or operator capx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)