[Question] Lifetime

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

[Question] Lifetime

Postby Matten » Thu May 20, 2010 7:44 am

Does someone know how to give a geom a lifetime? I'm working on a fire simulator and I want that the fire"balls" dissapear after 5 sec. They don't touch something, so with onCollide it can't.
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: [Question] Lifetime

Postby KarateBrot » Thu May 20, 2010 8:24 am

Declare a new variable like "scene.my.time" and then use something similar:
Code: Select all
(scene.addCircle{pos := app.mousepos; scene.my.time = sim.time}).density  = {sim.time - scene.my.time <= 5 ? {2} : {0}}
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: [Question] Lifetime

Postby tatt61880 » Thu May 20, 2010 10:07 am

KarateBrot wrote:Declare a new variable like "scene.my.time" and then use something similar:
Code: Select all
(scene.addCircle{pos := app.mousepos; scene.my.time = sim.time}).density  = {sim.time - scene.my.time <= 5 ? {2} : {0}}


Be careful, density = 0 will crashes Phun. It works well only with Algodoo.
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: [Question] Lifetime

Postby KarateBrot » Thu May 20, 2010 4:20 pm

yeah but we're in the algodoo forums and he didn't say he's using phun, right? :D

for phun use airfrictionmult = NaN instead of density = 0
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: [Question] Lifetime

Postby Matten » Thu May 20, 2010 8:52 pm

That's a good script, but what I want to have is that every "ball", deletes (I use a simple delete script with no collide and invisible) 5 seconds after his creation. So not that all balls dissapear after 5 sec.
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: [Question] Lifetime

Postby KarateBrot » Thu May 20, 2010 11:16 pm

so then just use object variables
Code: Select all
(scene.addCircle{pos := app.mousepos; controlleracc := sim.time}).density  = {sim.time - controlleracc <= 5 ? {2} : {0}}


but it only works if you go to the scripting menu of each circle and press enter after you clicked into the density line. maybe a bug?? it's because of "sim.time - controlleracc <= 5". every time there is more than one variable it's very bitchy.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: [Question] Lifetime

Postby Matten » Fri May 21, 2010 8:09 am

I've tried the script and it didn't work like you said. I will try it on another way.
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: [Question] Lifetime

Postby Versieon » Fri May 21, 2010 11:27 pm

I tryed this in onLaserhit
Code: Select all
(e)=>{
    (scene.addCircle({
        pos := e.pos;
        eval("scene.my.my" + e.geom.controllerAcc + " = sim.time")
    })).density = {sim.time - eval("scene.my.my" + e.geom.controllerAcc) <= 5 ? {2} : {0}};
    e.geom.controllerAcc = e.geom.controllerAcc + 1
}


But instead of creating new variables each time, it shut down Algodoo and didn't record anything in the log file...
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: [Question] Lifetime

Postby Chronos » Sat May 22, 2010 4:15 am

Maybe it has to do with the quotes around scene.my.my?
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: [Question] Lifetime

Postby tatt61880 » Sat May 22, 2010 1:50 pm

KarateBrot wrote:so then just use object variables
Code: Select all
(scene.addCircle{pos := app.mousepos; controlleracc := sim.time}).density  = {sim.time - controlleracc <= 5 ? {2} : {0}}


but it only works if you go to the scripting menu of each circle and press enter after you clicked into the density line. maybe a bug?? it's because of "sim.time - controlleracc <= 5". every time there is more than one variable it's very bitchy.


Could you make a bug report for this?
This bug were reported by one Japanese several days ago.
These days, I've searched this forum about this bug.

This bug seems to be something to do with "namespace".

I found a same kind of bug report.
viewtopic.php?f=11&t=112&p=946#p946
(
Declaring global variable named "size" etc. is not good because of name conflict. This bug were fixed by v1.6.4.
Readme.txt wrote:* Global variables with names conflicting with entity attributes (e.g. "color", "pos" etc) no longer interferes with deserialization

)
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: [Question] Lifetime

Postby Rrobba » Sat May 22, 2010 3:05 pm

tatt61880 wrote:
KarateBrot wrote:Declare a new variable like "scene.my.time" and then use something similar:
Code: Select all
(scene.addCircle{pos := app.mousepos; scene.my.time = sim.time}).density  = {sim.time - scene.my.time <= 5 ? {2} : {0}}


Be careful, density = 0 will crashes Phun. It works well only with Algodoo.


This. If you use Phun then it will most probably crash instantly so be careful. If you use Algodoo though you should be OK.
Image
I don't suffer from insanity. I enjoy every minute of it.
User avatar
Rrobba
[Best Sig 2010]
 
Posts: 1480
Joined: Mon Aug 31, 2009 6:01 pm
Location: Gibraltar

Re: [Question] Lifetime

Postby KarateBrot » Sat May 22, 2010 5:27 pm

Rrobba wrote:This. If you use Phun then it will most probably crash instantly so be careful. If you use Algodoo though you should be OK.

That's what tatt already said :?
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: [Question] Lifetime

Postby Matten » Sun May 23, 2010 9:19 am

To prevent useless discussions, I use Algodoo.
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: [Question] Lifetime

Postby KarateBrot » Thu May 27, 2010 3:26 am

that's gonna be very interesting for your fire simulator
http://www.algodoo.com/forum/viewtopic.php?f=13&t=1322&p=26937#p26885
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: [Question] Lifetime

Postby Matten » Thu May 27, 2010 7:05 pm

I think this will work, but at the moment Algodoo is very slow (first it wasn't). So I haven't tried it yet.
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: [Question] Lifetime

Postby Rideg » Sat Jun 12, 2010 2:03 am

*Bump*

Well perhaps you've solved this already but I'm doing a lighter that spawns circles adn make them collide with a box that changes their collision and triggers their onCollide. The circles have 1 sec before they disappear(density = 0); Here's the onCollide script it might help

Code: Select all
onCollide := (e)=>{
                e.this.controllerAcc = e.this.controllerAcc + sim.time;
                e.this.density = {sim.time >= controllerAcc ? {0} : {0.001}};
                e.this.onCollide = (e)=>{}
            }


ControllerAcc is the time it should "live" then I add the "sim.time" variable and make an "wannabe" if-statement that's controlling when the density should be 0. And it also disables the onCollide of the circle to prevent add lifetime to the circle.

Hope it'll work works fine for me ;)
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: [Question] Lifetime

Postby Matten » Sat Jun 12, 2010 8:14 am

Thank's for help, but I've found another (better) way. I have a laser in the fire balls with a time script. With this way I've also made a cluster bomb.
Rating: rated 5.7
Filesize: 9.07 kB
Comments: 3
Ratings: 3
download
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: [Question] Lifetime

Postby Rideg » Sat Jun 12, 2010 11:29 am

okey well it lagged my computer shitless with lasers that's why I declared the dynamic variables via onCollide I'll check that scene now ;)
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 5 guests

cron