Stack Overflow

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

Stack Overflow

Postby l4m2 » Sat Jul 02, 2016 6:41 am

Code: Select all
n=180;
for(2*n,(i)=>{
Scene.addCircle({
    attractionType := 1;
    attraction := 1.00000000;
    friction := 0.00000000;
    color := [0, 0, 0, 1];
    drawCake := false;
    pos := [2*math.sin(math.pi/n*i), 2*math.cos(math.pi/n*i)];
    onDie := (e)=>{};
    density := 2.0000000;
    radius := 0.015625000;
    angvel := 0.00000000;
    heteroCollide := false;
    glued := true;
    onKey := (e)=>{};
    opaqueBorders := true;
    body := 0;
    edgeBlur := 0.00000000;
    zDepth := 4.0000000;
    layer := 0
})})
gets an StackOverflow and draw only 66 circles. I tried to shorten the stack calling:
for2=(b,n,f)=>{
n<2?{
n<1?{
f(b)
}:0
}:{
t=math.toint(n);
for2(b,t,f);
for2(b+t,n-t,f);
}
};
but only one circle was drawed
l4m2
 
Posts: 42
Joined: Fri Jun 27, 2014 6:21 am

Re: Stack Overflow

Postby l4m2 » Sun Jul 03, 2016 4:19 pm

Although this code is okay, not the same way as easier thinking
Code: Select all
Scene.addCircle({
    pos:=[0,0];
    radius:=1;
    collideset:=0;
    collidewater:=false;
    friction:=0;
    update:=(e)=>{
   n=180;
   i = friction;
   friction>=2*n ? {
       timetolive = -1
   } : {
       Scene.addCircle({
      attractionType := 1;
      attraction := 1.00000000;
      friction := 0.00000000;
      color := [0, 0, 0, 1];
      drawCake := false;
      pos := [2*math.sin(math.pi/n*i), 2*math.cos(math.pi/n*i)];
      onDie := (e)=>{};
      density := 2.0000000;
      radius := 0.015625000;
      angvel := 0.00000000;
      heteroCollide := false;
      glued := true;
      opaqueBorders := true;
      body := 0;
      edgeBlur := 0.00000000;
      zDepth := 4.0000000;
      layer := 0
       })
        };
   friction=friction+1;
    }
})
l4m2
 
Posts: 42
Joined: Fri Jun 27, 2014 6:21 am

Re: Stack Overflow

Postby icrls984 » Mon Jul 04, 2016 10:09 am

I don't know why, I can't seem to get more than 65~~ runs of the code thing either. I just usually make it spawn objects that spawn more objects.
.
User avatar
icrls984
 
Posts: 80
Joined: Thu Jun 13, 2013 6:33 am

Re: Stack Overflow

Postby Kilinich » Mon Jul 04, 2016 8:52 pm

Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Stack Overflow

Postby l4m2 » Tue Jul 05, 2016 2:36 am

Two places modified:
Code: Select all
for2=(b,n,f)=>{n<2?{n>0?{f(b)}:0}:{t=math.toint(n/2);for2(b,t,f);for2(b+t,n-t,f);}};

But when run it dies for a time
l4m2
 
Posts: 42
Joined: Fri Jun 27, 2014 6:21 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 15 guests

cron