what is for(5 (i)=>{..........}

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

what is for(5 (i)=>{..........}

Postby jessebax129 » Wed Jun 30, 2010 9:17 pm

hi i saw ones in a topic:
oncollide:= (e)=>{ for(5 (i)=>{scene.addcircle({pos:=e.pos;heterocollide:=true})}}
what does that mean (''for(5 (i)=>{......}
does it mean that it spawns 5 balls per time collide?
jessebax129
 
Posts: 34
Joined: Tue Jan 05, 2010 6:32 pm

Re: what is for(5 (i)=>{..........}

Postby Rideg » Wed Jun 30, 2010 11:02 pm

Exactly! It repeats the script five times if used right. You can try it and see for yourself. ;)
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: what is for(5 (i)=>{..........}

Postby jessebax129 » Thu Jul 01, 2010 2:11 pm

Rideg wrote:Exactly! It repeats the script five times if used right. You can try it and see for yourself. ;)


wow okay but how does the script look like? it doesn't work with (e)=>{ for(5 (i)=>{scene.addcircle({....})} :crazy:
jessebax129
 
Posts: 34
Joined: Tue Jan 05, 2010 6:32 pm

Re: what is for(5 (i)=>{..........}

Postby Rideg » Thu Jul 01, 2010 9:25 pm

jessebax129 wrote:
Rideg wrote:Exactly! It repeats the script five times if used right. You can try it and see for yourself. ;)


wow okay but how does the script look like? it doesn't work with (e)=>{ for(5 (i)=>{scene.addcircle({....})} :crazy:


You wrote wrong. (e)=>{for(5, (i)=>{scene.addCircle({radius := 0.5; color := [0.0, 0.0, 0.0, 1.0]; pos := e.pos; })})}

You forgot the comma (,) between (5 and (i)=>{}.
You wrote for(5 (i)=>{}
This works(5, (i)=>{}
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest