change code of another object

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

change code of another object

Postby jordan30001 » Sun Aug 22, 2010 4:39 am

hey is there a way to change the code of another object

Code: Select all
(e)=>{e.other.color = [0, 1, 0]; e.other.colide = [e.other.color = {0, 1 ,0}}


how could i acomplish this or is it even possible?
jordan30001
 
Posts: 11
Joined: Mon Aug 16, 2010 4:03 pm

Re: change code of another object

Postby Versieon » Sun Aug 22, 2010 5:55 am

well seeing all the mistakes besides your question, I would first check out the tutorials on scripting here. Then you should be better able to acomplish what you want to do, which is, by the way, this.
Code: Select all
(e)=>{e.other.color = [0, 1, 0, 1]; e.other.onCollide = (e)=>{e.other.color = [0, 1 ,0, 1]}}
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: change code of another object

Postby jordan30001 » Sun Aug 22, 2010 6:20 am

(e)=>{e.other.color = [0, 1, 0, 1]; e.other.onCollide = (e)=>{e.other.color = [0, 1 ,0, 1]}}
whats the fourth 1 in [0, 1, 0, 1] ?

also could i do this and make it loop infinite times

(e)=>{e.other.color = [0, 1, 0, 1]; e.other.onCollide = (e)=>{e.other.color = [0, 1 ,0, 1]; e.other.onColide = (e)=>{e.other.color = [0, 1, 0, 1}}}

also while im hear is there a way to randomly pick a colour out of a list say like

[1, 0, 0]
[0, 1, 0]
[0, 0, 1]
jordan30001
 
Posts: 11
Joined: Mon Aug 16, 2010 4:03 pm

Re: change code of another object

Postby Versieon » Sun Aug 22, 2010 6:56 am

colors are in RGBA or HSVA format, both of which uses four numbers to correlate to a color.
so the fourth 1 means that the color will be fully opaque.

to loop the effect forever, you will only need to put this.

Code: Select all
(e)=>{e.other.color = [0, 1, 0, 1]; e.other.onCollide = e.this.onCollide}


picking a list randomly from a list is a bit more complicated, although colors are random if not specified.
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 3 guests