[Question] Lifetime
18 posts • Page 1 of 1
[Question] Lifetime
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!
-
Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: [Question] Lifetime
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}}
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: [Question] Lifetime
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).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-
tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: [Question] Lifetime
yeah but we're in the algodoo forums and he didn't say he's using phun, right?
for phun use airfrictionmult = NaN instead of density = 0
for phun use airfrictionmult = NaN instead of density = 0
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: [Question] Lifetime
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!
-
Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: [Question] Lifetime
so then just use object variables
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.
- 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.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: [Question] Lifetime
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!
-
Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: [Question] Lifetime
I tryed this in onLaserhit
But instead of creating new variables each time, it shut down Algodoo and didn't record anything in the log file...
- 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...
-
Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: [Question] Lifetime
Maybe it has to do with the quotes around scene.my.my?
TheWinkits wrote:They both looks of cuking amazing
-
Chronos - [Most Active Member 2010]
- Posts: 4457
- Joined: Mon Aug 31, 2009 6:00 pm
- Location: Californania
Re: [Question] Lifetime
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).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-
tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: [Question] Lifetime
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.
I don't suffer from insanity. I enjoy every minute of it.
-
Rrobba - [Best Sig 2010]
- Posts: 1480
- Joined: Mon Aug 31, 2009 6:01 pm
- Location: Gibraltar
Re: [Question] Lifetime
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
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: [Question] Lifetime
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!
-
Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: [Question] Lifetime
that's gonna be very interesting for your fire simulator
http://www.algodoo.com/forum/viewtopic.php?f=13&t=1322&p=26937#p26885
http://www.algodoo.com/forum/viewtopic.php?f=13&t=1322&p=26937#p26885
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: [Question] Lifetime
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!
-
Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: [Question] Lifetime
*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
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
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
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: [Question] Lifetime
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.
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!
-
Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: [Question] Lifetime
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
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
18 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 15 guests