Can I check values with "|" in expression?

Discussion and feedback on Construct 2

Post » Tue Aug 22, 2017 9:36 pm

Can I check values with "|" in expression? Cause I tired that with checking array value and it doesn't work. But maybe I'm doing something wrong? cheers
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
91
S
30
G
22
Posts: 1,985
Reputation: 20,149

Post » Tue Aug 22, 2017 10:02 pm

I don't get it... Are you trying to convert a String into an array separating by "|"?

If yes, you can use the tokenat() System expression.

Some type of source wrote:tokenat(Text, Index, Separator)
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 » Tue Aug 22, 2017 10:06 pm

HenryPK wrote:I don't get it... Are you trying to convert a String into an array separating by "|"?

If yes, you can use the tokenat() System expression.

Some type of source wrote:tokenat(Text, Index, Separator)



No, I'm talking about condition Array.curx, Array.cury = "A" | "B" . This doesn't seam to work.
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
91
S
30
G
22
Posts: 1,985
Reputation: 20,149

Post » Tue Aug 22, 2017 10:13 pm

Array.cury = "A" | Array.cury ="B"
ImageImageImage
B
71
S
22
G
248
Posts: 3,761
Reputation: 138,073

Post » Tue Aug 22, 2017 10:28 pm

Another source wrote:Compare two values

Array.CurX = "A" | Array.CurY = "B"

Equals (=)

true



(Array.CurX = "A" OR Array.CurY = "B")

Just keep in mind that CurX and CurY are excluive of FOR EACH loops, and are numbers oH< *
Last edited by HenryPK on Tue Aug 22, 2017 10:41 pm, edited 1 time in total.
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 » Tue Aug 22, 2017 10:34 pm

Image
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Tue Aug 22, 2017 11:51 pm

Awesome, thanks guys. Will check it out.
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
91
S
30
G
22
Posts: 1,985
Reputation: 20,149

Post » Tue Aug 22, 2017 11:56 pm

More like:
(x=a|x=b)=1 ?foo :foo2
It returns a Boolean.
Image ImageImage
B
171
S
50
G
179
Posts: 8,394
Reputation: 113,482

Post » Wed Aug 23, 2017 12:45 am

newt wrote:More like:
(x=a|x=b)=1 ?foo :foo2
It returns a Boolean.


What's foo? Function?

Could you expand your example? Just bit confused. Atm I want to check weather a value at current X and Y is = A or B. Then I want to follow with actions. But I'm open to learning more too.
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
91
S
30
G
22
Posts: 1,985
Reputation: 20,149

Post » Wed Aug 23, 2017 2:03 am

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.
Image ImageImage
B
171
S
50
G
179
Posts: 8,394
Reputation: 113,482

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 10 guests