Help Making Alerts

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

Help Making Alerts

Postby phunHunger » Tue May 25, 2010 9:41 pm

Code: Select all
alert = (a,b,c,d,e)=>{
                     //bcolor, bsize, bpos, btext, bdelay
    Scene.addBox({
        color   := a;      //bcolor
        size   := b;      //bsize 
        pos      := c;      //bpos
      text   := d;      //btext
      collideSet   := 1;
        friction   := Sim.time + e; //bdelay and simtime
      body       := 0;
        drawBorder   := {Sim.time > friction ? {density = 0} : {};true;};
    });
};   


This is my code for to make a box with some text in it, with a certain colour, at a certain position and with a certain size. It should also destroy itself after a certain amount of seconds using density=0.

    Normal attributes made.
    Friction contains spawnTime + time allowed to appear for.
    drawBorder contains code to check for expiration.

It doesn't work :( ...

When the box is spawned, it does NOT disapear after any amount of time. However, the box will disapear if I click on the drawBorder text box and press ENTER.

Any ideas??

Thanks for your help, phunHunger.
Noobs are the best ;)
User avatar
phunHunger
 
Posts: 31
Joined: Mon Apr 26, 2010 10:01 pm

Re: Help Making Alerts

Postby KarateBrot » Wed May 26, 2010 9:51 am

the problem is you can't spawn objects with dynamic properties. it got discussed a few months ago and it's up to date again right now here in the thyme section. there's a workaround so that it gets dynamic by kilinich.
http://www.algodoo.com/forum/viewtopic.php?f=13&t=1322
but you can only make ONE property dynamic. that's the disadvantage. but it's definitely way better than nothing.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

It Works Now :)

Postby phunHunger » Wed May 26, 2010 4:23 pm

Code: Select all
alert = (a, b, c, d, e)=>{
    (Scene.addBox{
        color := a;
        size  := b;
        pos   := c;
        text  := d;
        collideSet := 1;
        body  := 0;
    }).density = eval("{Sim.time > "+ (Sim.time + e) +" ? {0} : {1};}");
};


This is the new code, it works well so far. I used a bit of eval so i didn't need two variables being used at the same time.

Thanks very much for your help :D
Noobs are the best ;)
User avatar
phunHunger
 
Posts: 31
Joined: Mon Apr 26, 2010 10:01 pm

Re: Help Making Alerts

Postby KarateBrot » Thu May 27, 2010 2:53 am

yeah no problem
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 5 guests