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

Get help using Construct 2

Post » Thu Apr 25, 2013 5:40 am

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?
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
112
S
20
G
8
Posts: 741
Reputation: 13,636

Post » Thu Apr 25, 2013 10:48 am

ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Thu Apr 25, 2013 3:40 pm

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


A simple reversal of the logic could also emulate a logical AND... but it's quite useless considering Construct already does that !

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
Magistross2013-04-25 15:44:00
B
46
S
17
G
18
Posts: 847
Reputation: 13,802

Post » Thu Apr 25, 2013 6:13 pm

@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.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
112
S
20
G
8
Posts: 741
Reputation: 13,636

Post » Thu Apr 25, 2013 6:38 pm

Here's a simple yet working example to help you understand how it could work.
B
46
S
17
G
18
Posts: 847
Reputation: 13,802

Post » Thu Apr 25, 2013 6:47 pm

@Magistross - Thank you, sir! I'll check it out later on (gots me a job interview to prepare for :) ).
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
112
S
20
G
8
Posts: 741
Reputation: 13,636

Post » Sat Dec 21, 2013 10:08 am

[QUOTE=Magistross] You can emulate a logical OR with a function. As pictured here.


A simple reversal of the logic could also emulate a logical AND... but it's quite useless considering Construct already does that !

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
[/QUOTE]
it's very useful for working on sitelock, thanks Magistross!
B
6
S
1
G
1
Posts: 39
Reputation: 828

Post » Sat Dec 21, 2013 10:26 am

Could you use the or operator for this?

So in your case this would become:

System compare two values: Variable="This" | Variable="That" = 1LittleStain2013-12-21 10:38:36
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Post » Sat Dec 21, 2013 10:50 am

Or Operator html example
(use left and right arrow keys to change the number)

Or operator capxLittleStain2013-12-21 10:51:37
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest