programming (general)

Chat about anything not covered in these forums, but keep it civil!

Post » Sun Sep 04, 2011 11:35 pm

[QUOTE=shinkan] Shame it doesn't work with text variables :)[/QUOTE]
don't know about construct, but most languages let you do that:

stringvar == "The Right Answer" ? "good job!" : "aww, you're lame"
Spriter Dev
B
96
S
21
G
12
Posts: 3,256
Reputation: 16,813

Post » Sun Sep 04, 2011 11:45 pm

In C2 it says
[code] Type mismatch
= does not work with 'integer' and 'string' (use & to build strings)[/code]
ImageImageImageImage
B
155
S
61
G
41
Posts: 2,577
Reputation: 34,314

Post » Mon Sep 05, 2011 12:15 am

rogerty, in answer to your original question. Being able to recognize and appreciate an elegant solution may be a sign that you have the capacity to create them as well. I think the more you see, and the more you try to think in that direction the more often you will come up with elegant solutions to your problems. Over the years I've come up with code I thought was clever or elegant now and then, but I still see something simple like this from time to time, and wonder why I hadn't thought of it myself. The particular example you asked about was one such case when I first saw it.
Spriter Dev
B
96
S
21
G
12
Posts: 3,256
Reputation: 16,813

Post » Mon Sep 05, 2011 1:29 am

Here is another one:

Automatically loop-count x from 1 to n repeatedly

x = (x % n) + 1



EDIT:
[QUOTE=shinkan] In C2 it says
[code] Type mismatch
= does not work with 'integer' and 'string' (use & to build strings)[/code][/QUOTE]
In CC it works when the testvar is a number, e.g.

[code]Text: Set text to global('test') = 0 ? "Value is zero" : "Value is non-zero"[/code]tulamide2011-09-05 01:36:00
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Mon Sep 05, 2011 1:35 am

[QUOTE=shinkan] In C2 it says
[code] Type mismatch
= does not work with 'integer' and 'string' (use & to build strings)[/code][/QUOTE]
Oops, looks like a bug. Will try have that fixed for next build.
Scirra Founder
B
378
S
219
G
84
Posts: 23,860
Reputation: 187,903

Post » Mon Sep 05, 2011 1:42 am

[QUOTE=tulamide] Here is another one:

Automatically loop-count x from 1 to n repeatedly

x = (x % n) + 1[/QUOTE]

could you show me an example of that? can't get it to work :/


ImageImageImageImage
B
155
S
61
G
41
Posts: 2,577
Reputation: 34,314

Post » Mon Sep 05, 2011 2:40 am

Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Mon Sep 05, 2011 5:11 am

One thing I've noticed in CC "%" isn't displayed correctly.
It just says something like =0.... kinda confusing sometimes.
Image ImageImage
B
164
S
49
G
138
Posts: 7,946
Reputation: 91,858

Post » Mon Sep 05, 2011 5:29 am

Another way to do this is have:

+M pressed
+Var = 0
->wait 10ms
->Var == 1

Vice versa for the second one.

Ashley's sounded fun though. I'm going to try it now!
B
28
S
7
G
5
Posts: 202
Reputation: 5,285

Post » Mon Sep 05, 2011 6:35 am

conditional_expression == "pure awesomeness" ? "pure awesomness":"pure awesomness" harrio2011-09-05 06:37:49
B
77
S
30
G
20
Posts: 1,053
Reputation: 33,307

PreviousNext

Return to Open Topic

Who is online

Users browsing this forum: bscych and 1 guest