Self-delition codes needed

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

Self-delition codes needed

Postby Nait » Sun Jun 13, 2010 10:34 am

Hello people, it happened that I also need your help...
I need codes for self-delition of object, I know one of them
Code: Select all
oncollide:=(e)=>{controlleracc=sim.time; density={sim.time-controlleracc>1.5?{0}:{6}}; oncollide=(e)=>{}}

But it is quiet laggy, if you know some other please tell me.
User avatar
Nait
 
Posts: 224
Joined: Fri Oct 30, 2009 1:56 am
Location: Eastern Russia, Vladivostok

Re: Self-delition codes needed

Postby savask » Sun Jun 13, 2010 10:50 am

Code: Select all
AirfrictionMult = NaN
is working in Phun also.
User avatar
savask
 
Posts: 162
Joined: Mon Oct 12, 2009 2:53 pm
Location: Russia, Siberia

Re: Self-delition codes needed

Postby Matten » Sun Jun 13, 2010 11:42 am

For Phun use airFrictionMult = NaN
For Algodoo use density = 0
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: Self-delition codes needed

Postby Rideg » Sun Jun 13, 2010 11:47 am

I don't think there's a way to make it less laggy.

The only way I can think of is that it get's a collideLife.
When it collides 10 times it gets deleted.

Code: Select all
(e)=>{e.this.refractiveIndex = e.this.refractiveIndex + 1; e.this.refractiveIndex >= 10 ? {e.this.density = 0}:{}}
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: Self-delition codes needed

Postby Nait » Mon Jun 14, 2010 8:11 am

I meant way of counting time, not way of code delitiong...

Thank you Rideg, but when gunpowder explodes amount of collisions is not stable, maybe spawning lasers fixed to objects and making "LaserHitLife"...
User avatar
Nait
 
Posts: 224
Joined: Fri Oct 30, 2009 1:56 am
Location: Eastern Russia, Vladivostok

Re: Self-delition codes needed

Postby Rideg » Mon Jun 14, 2010 11:41 am

Well I've got a solution IF the circles that should have a lifetime COLLIDES.

I think you're making an explosion so that will make this possible.
This will spawn 5 circles at the same position and when ten seconds have passed they will delete themselves.
Code: Select all
(e)=>{
    for(5, (i)=>{
        Scene.addCircle({
            color := [0.0, 0.0, 0.0, 1.0];
            onCollide := (e)=>{
                e.this.controllerAcc = e.this.controllerAcc + sim.time;
                e.this.density = {sim.time >= controllerAcc ? {0} : {2.0}};
                e.this.onCollide = (e)=>{}
            };
            controllerAcc := 10;
            collideSet := 64;
            pos := e.pos;
            radius := 0.01
        })
    })
}


Put that in in any any onCollide/onHitByLaser/onLaserHit script box and it will spawn circles with a ten seconds lifetime.

I wrote a longer post but my computer decided to mess with me and somehow it all got deleted. I also made a Example scene´but I don't know how to post scenes with the post.

Hope this helped. ;)
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: Self-delition codes needed

Postby Nait » Tue Jun 15, 2010 2:38 am

Oh man, thanks, it isn't very different from my code, but mutch less lagging, even if there are 100 circles spawned! :clap:
This helps :D

PS
In scene details, at left under information is textbox "scene tag". Copy code and past it where you need.
Looks like
Code: Select all
[scene]number[/scene]
User avatar
Nait
 
Posts: 224
Joined: Fri Oct 30, 2009 1:56 am
Location: Eastern Russia, Vladivostok

Re: Self-delition codes needed

Postby Matten » Tue Jun 15, 2010 10:42 am

Rideg wrote:but I don't know how to post scenes with the post.

Why do you forget this every time, this is the thirth time I see you asking this....
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: Self-delition codes needed

Postby Rideg » Tue Jun 15, 2010 11:08 am

no making an attachment I've known how to post scenes in a post since I joined the forum. Last time I asked here was a malfuncion with the site ;)
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 3 guests