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
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

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
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

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
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

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
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

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
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

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
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Mon Sep 05, 2011 2:40 am

Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

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 Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

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
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Mon Sep 05, 2011 6:35 am

conditional_expression == "pure awesomeness" ? "pure awesomness":"pure awesomness" harrio2011-09-05 06:37:49
B
50
S
17
G
15
Posts: 1,029
Reputation: 26,289

PreviousNext

Return to Open Topic

Who is online

Users browsing this forum: Sasha555666 and 1 guest