Spawning a circle then deleting it.

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

Spawning a circle then deleting it.

Postby Dadasas » Sat Dec 19, 2009 5:02 pm

I want to make something spawn a circle and then the circle is erased in a second without the circle hitting anything, Is it possible?
User avatar
Dadasas
 
Posts: 46
Joined: Tue Sep 01, 2009 2:03 am

Re: Spawning a circle then deleting it.

Postby KarateBrot » Sat Dec 19, 2009 5:11 pm

Code: Select all
(e) => { scene.addcircle({collideset := 0; airfrictionmult := NaN}) }

But you need air friction for it to work
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Spawning a circle then deleting it.

Postby Dadasas » Sat Dec 19, 2009 6:01 pm

I want the circle to stay there for a second or more like 10 seconds, I don't want scene.my thing, I also want it possible to make more than one at the same time.
User avatar
Dadasas
 
Posts: 46
Joined: Tue Sep 01, 2009 2:03 am

Re: Spawning a circle then deleting it.

Postby RA2lover » Sat Dec 19, 2009 6:32 pm

you can use the for(number of times you want to, (variable if you want to change something according to spawns)=>{script to be executed}) function(a looping structure) to avoid having to type everything tons of times.

for the time-limit, you might want to use a built-in variable, stored in the circle itself, and put on the density value something like that
{timetodeleteobject <= sim.time ? 0 : density of normal object}

also, i'm assuming you're using algodoo, as using density = 0 in A:PE can cause crashes.
Jrv wrote:
TC42 wrote:Quite honestly, I didn't think anyone on 4chan has that good a use of grammar, spelling, usage, mechanics, ect.
But I've never been there, so I may be wrong.


GTFO newfgt
User avatar
RA2lover
 
Posts: 607
Joined: Mon Aug 31, 2009 8:43 pm
Location: Brazil

Re: Spawning a circle then deleting it.

Postby Dadasas » Sat Dec 19, 2009 7:18 pm

Hmm, So if I wanted to make it be deleted in 5 sim.time units after being spawned , how would I do that?
User avatar
Dadasas
 
Posts: 46
Joined: Tue Sep 01, 2009 2:03 am

Re: Spawning a circle then deleting it.

Postby KarateBrot » Sat Dec 19, 2009 8:27 pm

if you want to spawn an object before the last one gets deleted it can be a problem because the script will be deleted from the first object that was spawned.

If you want it to last 5 time units and if only one circle every 5 units is spawned this works:
Code: Select all
(e) => { scene.addcircle({spawntime := sim.time; density := {(sim.time - spawntime) > (5.0 / sim.frequency) ? {0} : {2.0}} }) }


But are you using phun or algodoo? This is important to know.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Spawning a circle then deleting it.

Postby Dadasas » Sat Dec 19, 2009 8:35 pm

Algodoo. Thanks for all your help.
Last edited by Dadasas on Sat Dec 19, 2009 8:37 pm, edited 1 time in total.
User avatar
Dadasas
 
Posts: 46
Joined: Tue Sep 01, 2009 2:03 am

Re: Spawning a circle then deleting it.

Postby KarateBrot » Sat Dec 19, 2009 8:36 pm

Ok it will work then. Otherwise you'd have to use airfrictionmult = NaN instead of density = 0
try it. If it's too fast use a higher number than 5.0

And you really want to delete it after 5 time units and not 5 seconds or something like that?
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Spawning a circle then deleting it.

Postby Dadasas » Sat Dec 19, 2009 9:10 pm

Okay , but why can it only spawn one at a time?
User avatar
Dadasas
 
Posts: 46
Joined: Tue Sep 01, 2009 2:03 am

Re: Spawning a circle then deleting it.

Postby KarateBrot » Sun Dec 20, 2009 3:40 am

You can spawn more at a time but then only the last spawned will be deleted. the others will stay because once a new object is spawned before the last one is deleted the script gets deleted from the old one and only works for the new spawned object. i don't know why this happens. maybe a bug.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Spawning a circle then deleting it.

Postby Dadasas » Sun Dec 20, 2009 6:48 pm

Hmm, well my problem is solved, Thanks everybody!
EDIT : One quick question, is it possible to make an if statement that ask if the other thing is water?
User avatar
Dadasas
 
Posts: 46
Joined: Tue Sep 01, 2009 2:03 am

Re: Spawning a circle then deleting it.

Postby blahblah200 » Sun Dec 20, 2009 11:59 pm

Yes - e.other + "" is how you work out what it is (I am not sure if I have spelt it right) - so this is the code -
Code: Select all
e.other + "" == "water" ? {What happens if it IS water} : {What happens if it ISN'T water}


You can also make it so it can recognise what type of geomitery the other thing is -
if it's a plane - e.other + "" equals "plane"
if it's a box - e.other + "" equals "box"
if it's a polygon - e.other + "" equals "polygon"
and so on - you get the idea
Image<-- Made with GIMP
User avatar
blahblah200
 
Posts: 61
Joined: Tue Sep 01, 2009 11:33 am
Location: Somewhere over the rainbow...

Re: Spawning a circle then deleting it.

Postby KarateBrot » Mon Dec 21, 2009 12:09 am

No that doesn't work. I already tried it. I only know this kind of code for the normal geometries but not for water. I also tried "splash of water" but that doesn't work, too
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 1 guest

cron