Can I check values with "|" in expression?

Discussion and feedback on Construct 2

Post » Wed Aug 23, 2017 11:14 am

newt wrote:Its a conditional. It tests if a statement is true, and says what to do if it's true (?), and what to do if it's not(:)
1=1 ?set x to 9 :set x to 2
Since 1 is equal to 1 it would do whatever follows the question mark.
If it wasn't it would set it to whatever was after the colon.


Ok. So you are saying I should add brackets? I don't need that part after ? at this point although I do use it sometimes.
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 » Wed Aug 23, 2017 5:18 pm

that‘s for JS, right?
Howdy, I'm HenryPK! I love helping people and making games... Hope we can be friends. (Also check my game: Blue)
B
10
S
2
G
1
Posts: 60
Reputation: 1,233

Post » Wed Aug 23, 2017 6:25 pm

| gets evaluated to either 1 or 0. 1 if either, or both are true, 0 if neither are true.
It does not return the value that was evaluated. You set that up in the conditionals "?", and ":".
So there's multiple parts.
The conditional:
statement ?value if true :else
The or as a statment:
(1=0|1=2)=0
No its not js, it's the dummied down version of parts of js.
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Wed Aug 23, 2017 10:37 pm

newt wrote:| gets evaluated to either 1 or 0. 1 if either, or both are true, 0 if neither are true.
It does not return the value that was evaluated. You set that up in the conditionals "?", and ":".
So there's multiple parts.
The conditional:
statement ?value if true :else
The or as a statment:
(1=0|1=2)=0
No its not js, it's the dummied down version of parts of js.


Sorry. I'm not sure how I should go about it. I'd like to turn those conditions in to one condition per image:
Image
or
Image

Could you give me example based on those?

Thanks
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 » Wed Aug 23, 2017 11:47 pm

It wouldn't go in the condition, it would go in the action.
Something like:
for each in array
-> object set opacity to (curx="r"|curx=1)=1 ?100 :0
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Wed Aug 23, 2017 11:52 pm

newt wrote:It wouldn't go in the condition, it would go in the action.
Something like:
for each in array
-> object set opacity to (curx="r"|curx=1)=1 ?100 :0


Well, ok, but I need it to be a condition, because then I need to add other actions.
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 » Thu Aug 24, 2017 12:10 am

These are one of the situations that made me make the Set plugin.

It allows you to make ORs in very elegant way like this
Image

You can also do it with TR_System plugin which is free, but lacks of other Set plugin feature and has many other unrelated things built in.
ImageImageImage
B
27
S
16
G
74
Posts: 977
Reputation: 41,673

Post » Thu Aug 24, 2017 3:14 pm

Thanks, but i'd just like to know how to do that condition, cause there is a way 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 » Thu Aug 24, 2017 4:23 pm

korbaach's post does what you want.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: Artpunk, Sockratease and 13 guests