Can someone remind me OR in comparing variable?

Discussion and feedback on Construct 2

Post » Sun Aug 17, 2014 4:03 pm

Hi,

I must have some amnesia or something, but I forgot if i can use OR ( "|" right? ) in condition comparing a variable, like varX = "A" | "B" | "C", and will that work?

Thanks! XD
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Sun Aug 17, 2014 4:05 pm

No: varX="A" | varX="B" | varX="C"
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Sun Aug 17, 2014 4:06 pm

No, you would have to compare (varX = "A" )|(varX = "B" )|(varX = "C") is equal to 1

| is the logic operator OR.
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 Aug 17, 2014 4:22 pm

Hey, thanks for quick reply. So which condition I can use for that? I want to compare instance's variable.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Sun Aug 17, 2014 4:32 pm

megatronx wrote:Hey, thanks for quick reply. So which condition I can use for that? I want to compare instance's variable.



I would say pick by evaluate
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 Aug 17, 2014 4:41 pm

Compare two values:
varX="A" | varX="B" | varX="C"
Equal to
1
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Sun Aug 17, 2014 4:45 pm

blackhornet wrote:Compare two values:
varX="A" | varX="B" | varX="C"
Equal to
1


Pretty sure you're right, but I don't understand the logic behind it! >.> Basically I want to compare if instance's object variable is either = string A, string B, or string C etc. How this would work with 1?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Sun Aug 17, 2014 4:46 pm

The result of a boolean comparison is either True or False, which is the equivalent of 1 or 0.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Sun Aug 17, 2014 4:51 pm

blackhornet wrote:The result of a boolean comparison is either True or False, which is the equivalent of 1 or 0.


Ah, I get it now! Awesome! Thanks guys!
So "(Objects.Type = "Doors" | Objects.Type = "Chest" | Objects.Type = "Gate" ) equal to 1" will work right?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Sun Aug 17, 2014 4:55 pm

Yes.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 10 guests