[Solved] Convert "rgb(0,64,255)" to use it as a variable

Get help using Construct 2

Post » Tue Feb 25, 2014 11:57 pm

Hi,

I have a string coming from a server I want to use as an expression :

[TEXT] Set font color to : "rgb(0,64,255)"

The problem is C2 refuse my string, asking me a number. I could'nt find answser in the actual posts (found answers with string concatenation but it is still a string).

Is there something like eval("rgb(0,64,255)") ?

Thanks.
Last edited by jhice on Wed Feb 26, 2014 4:28 pm, edited 1 time in total.
B
11
S
2
Posts: 69
Reputation: 819

Post » Wed Feb 26, 2014 2:12 am

The problem is because you're trying to send an expression as a string - you should just send the numbers.

[TEXT] Set font color to : rgb(servervalue1, servervalue2, servervalue3)

Or store the result of rgb(0,64,255) (you can check it at runtime) to the server and retrieve that instead.
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Wed Feb 26, 2014 11:14 am

Ok I see. I will go on the second option (result of color), but cant see it at runtime. I have the free version of C2, in the debug panel color does not appear. Or do I have to look elsewhere ?

Thanks

EDIT : found this topic, diggin it ;) https://www.scirra.com/forum/viewtopic.php?f=160&t=85796&p=687135&hilit=convert+rgb#p687135

PS : coming from AS and PHP, the "eval()" function is useful although it is sometimes a bad practice, perhaps that's why C2 doesn't provide it ^^
B
11
S
2
Posts: 69
Reputation: 819

Post » Wed Feb 26, 2014 11:28 am

C2 does provide JS execution in the Browser object, but you certainly should not use it in this case.
Scirra Founder
B
387
S
230
G
88
Posts: 24,249
Reputation: 192,450

Post » Wed Feb 26, 2014 11:46 am

I found the color formula here : https://www.scirra.com/forum/viewtopic.php?f=160&t=85796 and submitted it in the "How do I..." page (where I looked first ^^).

Can you give an example of JS execution in the browser ? (just for information).

Thanks
Amazing community and software :)
B
11
S
2
Posts: 69
Reputation: 819

Post » Wed Feb 26, 2014 12:31 pm

Here's an example why it is useful to know the color formula (where wsColor is a number value) :

Image
B
11
S
2
Posts: 69
Reputation: 819

Post » Fri Feb 28, 2014 11:40 am

Ashley wrote:C2 does provide JS execution in the Browser object, but you certainly should not use it in this case.

jhice wrote:Can you give an example of JS execution in the browser ? (just for information).

RTFM ^^
French developper based in La Rochelle/Tours
Machines I used to play or develop games : Amstrad, Atari, Amiga, PC, PS, Xbox, mobile
B
11
S
2
Posts: 69
Reputation: 819


Return to How do I....?

Who is online

Users browsing this forum: georeb, part12studios, Yahoo [Bot] and 11 guests