Loop help

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

Loop help

Postby Matten » Wed Jun 09, 2010 4:55 pm

I'm making a bomb with a laser as timer. If the controllerAcc comes to 0, the bomb with explode. I've made a script to spawn the "explosion". But he spawns only 2 circles!
Here's the script:
Code: Select all
(e)=>{
    e.geom.controllerAcc = e.geom.controllerAcc - 0.05;
    e.geom.controllerAcc <= 0 ? {
        for(10, {
            Scene.addCircle({
                pos := e.pos;
                radius := 0.1;
                color := [1, 0, 0, 1];
                drawCake := false
            })
        });
        e.geom.density = 0
    } : {}
}


PS: I will upload the scene later on.
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: Loop help

Postby Rideg » Wed Jun 09, 2010 5:15 pm

Code: Select all
(e)=>{
    e.geom.controllerAcc = e.geom.controllerAcc - 0.05;
    e.geom.controllerAcc <= 0 ? {
        for(10,(i)=>{
            Scene.addCircle({
                pos := e.pos;
                radius := 0.1;
                color := [1, 0, 0, 1];
                drawCake := false
            })
        });
        e.geom.density = 0
    } : {}
}
that should do it. It all gets messed up when you don't make a new "(x)=>" thing in the loop. ;)
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: Loop help

Postby Matten » Wed Jun 09, 2010 5:21 pm

Damn, totally forgot the (x)=>!
I thought already that I missed something, but I didn't knew what. Thanks!
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: Loop help

Postby Rideg » Wed Jun 09, 2010 8:07 pm

no problem
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 4 guests

cron