How do I use logical OR with strings?

Get help using Construct 2

Post » Fri Nov 14, 2014 10:17 pm

C2 is complaining about this expression ("= is a type mismatch, etc..."):

Code: Select all
Compare Two Values:

left(Controls.Get(ControlMenuObject.Type),3) = (MouseString_LMB | MouseString_MMB | MouseString_RMB)

equal to

TRUE(1)


Basically, I'm trying to see if a given string matches 1 of 3 values(global string vars). So, put more simply:

Code: Select all
string foo = "foobar"

Compare Two Values:

foo = ("foo" | "foobar" | "foobert")

equal to

TRUE
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Fri Nov 14, 2014 11:16 pm

You can do it like this:

Code: Select all
Compare two values:

foo = "foobar" | foo = "footaro" | foo = "fooji"

equal to

1(True)
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,116

Post » Fri Nov 14, 2014 11:37 pm

Alright, thanks. I thought there might be a shorthand for string comparisons where I wouldn't have to repeat a static comparator for each case, but it's really not a big problem...if I was dealing with more than a few values I'd just use an array instead.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Buddhika, Nicolas951, R0J0hound and 11 guests