if statment in the color field for spawned objects

About advanced scenes, and the Thyme scripting language used in Algodoo.

if statment in the color field for spawned objects

Postby RaRaMalum » Tue Sep 01, 2009 2:48 am

Lets say you have a circle spawner and you want it to add a thyme script to the color field of every circle spawned.
example code:
{{sim.time == 10} ? {[0,0,1,1]} : {[0,0,0,1]}}

The code will work if you type it in manually for an already existing object, but if you ask the spawner to type it in it simply solves the if statment and puts in the value.

So how do I get a spawner to type in the actuall if statment and not just the value?
Phundamentalists, come to the dark side.
We have much cooler toys.
User avatar
RaRaMalum
[Best newcomer 2010]
 
Posts: 280
Joined: Mon Aug 31, 2009 10:47 pm

Re: if statment in the color field for spawned objects

Postby KarateBrot » Tue Sep 01, 2009 3:01 am

add this to your scene.addCircle()
Code: Select all
color := {{sim.time == 10} ? {[0, 0, 1, 1]} : {[0, 0, 0, 1]}}

Or is the problem a different one?

[edit]
oh ok... just tested it out. now i know what your problem is. so forget about this post. :D
but that's weird... i try to do something else if i have an idea.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: if statment in the color field for spawned objects

Postby Chronos » Tue Sep 01, 2009 3:09 am

it doesnt automatically correct it. if sim.time is over 10 when it spawns, its gonna be black, no exceptions (unless the code is wrong)

if its still doing this when sim.tim ISNT over 10, something wrong then
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: if statment in the color field for spawned objects

Postby KarateBrot » Tue Sep 01, 2009 3:17 am

i know what's wrong...

the code is working and it changes the color after 10 seconds, that's no problem BUT that only happens to the latest spawned circle!
so if you spawn 5 circles and now wait the 5. circle will change its color. the other ones stay at black so this seems to be a bug. it's really worth reporting it.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests