Help with operator?: bug

New releases and general discussions.

Post » Thu Feb 19, 2009 1:19 am

[quote="Ashley":1a13l4p5]Hmm, actually I think I fixed it! :)[/quote:1a13l4p5]

What was wrong? Was it the HTML codes?
Image Image
Scirra Founder
B
125
S
37
G
25
Posts: 3,945
Reputation: 44,922

Post » Fri Feb 20, 2009 9:23 am

[quote="Mipey":3h13cqnq]Oh yeah, I was using this operator yesterday with the text object...

Set Text to Random(2)?"Shrubbery":"Marmalade"
I expected it to return either "Shrubbery" or "Marmalade", but... It crashed.

If you fixed it, I needn't worry anymore :)[/quote:3h13cqnq]

By the way, you can also do this with Arrays:
{"One", "Two", "Bananas"} at Random(3)
B
2
S
1
G
3
Posts: 71
Reputation: 1,142

Post » Fri Feb 20, 2009 9:36 am

[quote="Luomu":3opzn7rk]By the way, you can also do this with Arrays:
{"One", "Two", "Bananas"} at Random(3)[/quote:3opzn7rk]
I am humbled, kind sir. :o Why haven't I thought of such a simple thing myself?! *facepalm*
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Fri Feb 20, 2009 1:57 pm

I think arrays are 1-indexed, so you'd want (random(3) + 1)...
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Feb 22, 2009 8:50 pm

actually it doesn't look like an easy thing to get right, PHP5 also fudges the ternary operator precedence under certain conditions :P so I'm used to ALWAYS wrap in parenthesis
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Previous

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 2 guests