Whether a variable is equal to EITHER of a list of numbers?

Get help using Construct 2

Post » Sun Apr 27, 2014 12:00 am

Why doesn't this check whether the variable is equal to either of the list of numbers?
I want it to result true if the variable is equal to any of the numbers in this list. (Preferably without creating a ton of "or" blocks.)

Image
Last edited by ionC2 on Sun Apr 27, 2014 3:54 am, edited 2 times in total.
B
5
S
1
Posts: 16
Reputation: 416

Post » Sun Apr 27, 2014 12:07 am

Try int(tokenAt()), or array's have a condition "contains value".
Image ImageImage
B
169
S
50
G
169
Posts: 8,285
Reputation: 108,214

Post » Sun Apr 27, 2014 4:37 pm

Eh I don't think those will help me too much. The global variable is set at either of those 4 numbers, and if it's either of them, I want this one condition to result true. I can't rewrite the global variable into an array or anything else, I need to be able to compare multiple potential values of the global variable.

I guess I'll just have to do it the hard way and make a ton of " = 2.5" and "= 4" and "= 8" and "= 12" conditions for each level<number>achievements variable. Pain because there's 45 levels. :mrgreen:
B
5
S
1
Posts: 16
Reputation: 416

Post » Sun Apr 27, 2014 4:44 pm

Compare two values:
(Levelachidvement = 7)|(Levelachidvement = 8)
Equal to
1

X= y return 0 if false or 1 if true
A|B|C return 0 if A and B and C are all to 0, returns 1 otherwise
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Sun Apr 27, 2014 5:02 pm

Edit: Nevermind below, I changed the code significantly and made it much smaller so it's no big deal.


I'm really kind of a noob to all these expressions. Here's basically what I want to do, just need to know if there's a more efficient way to do it:

Image

level<number>achievements gets assigned a number. If it's 2.5 or 4 or 8 or 12, it should set egg1 to 1.
level<number>achievements gets assigned a number. If it's 7 or 8, it should set silver1 to 1.
level<number>achievements gets assigned a number. If it's 11 or 12, it should set gold1 to 1.

Right now I'll be going through and editing each global variable to change it to the next sequential level as I go down the list. I just wanted to minimize the amount of clicking and number changing I have to do. :)

I'm just going to open the event sheet in an editor and replace every "level1achievements" with "level2achievements" and so on in each Group. I think that's the fastest and most straightforward way to do it. Tedious, but I've done worse with this game haha. I do things the hard way.
B
5
S
1
Posts: 16
Reputation: 416


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, namaewayukidesu and 11 guests