Page 1 of 1

Loops?

PostPosted: Sat Sep 26, 2009 2:51 pm
by Grenade1950
How do you create loops, as in repeating something until a condition is met?

I really have no idea how to script in Thyme... Can someone make this script for me? I know how to liquify the object if it's touched... but I don't know how to liquify other objects, nor do I know how to liquify the touched object if it's not immortal.

Thanks!

Edit: Okay I got it to liquify other objects. Now I need it to detect the other object's immortal property...

Re: Liquify if not immortal?

PostPosted: Sat Sep 26, 2009 3:07 pm
by standardtoaster
Code: Select all
e.other.immortal == true ? {e.other.liquify} : {}

Re: Liquify if not immortal?

PostPosted: Sat Sep 26, 2009 3:11 pm
by Grenade1950
That didn't work... Also, I want it to liquify if NOT immortal

Re: Liquify if not immortal?

PostPosted: Sat Sep 26, 2009 3:21 pm
by Grenade1950
Nevermind I got it, thanks :D

(note to self: read tutorials more often)

edit: ... huh? It works in a block, but not in a group of little circles... Why not? :cry:

Re: Liquify if not immortal?

PostPosted: Sat Sep 26, 2009 3:50 pm
by standardtoaster
Sorry for sounding like a noob here but could you please post the script. >.> I seem to have a lot of trouble with checking for booleans.

Re: Liquify if not immortal?

PostPosted: Sat Sep 26, 2009 3:52 pm
by Grenade1950
Code: Select all
e.other.immortal ? {} : {e.other.liquify}


This should liquify whatever it touches if it's NOT immortal

Re: Liquify if not immortal?

PostPosted: Sat Sep 26, 2009 5:09 pm
by Grenade1950
Hmm. I ungrouped the circles and it seems to work now...?

Re: Liquify if not immortal?

PostPosted: Sat Sep 26, 2009 5:12 pm
by standardtoaster
Are you talking about the script that you posted or the one that I posted?

Re: Liquify if not immortal?

PostPosted: Sat Sep 26, 2009 5:16 pm
by Grenade1950
standardtoaster wrote:Are you talking about the script that you posted or the one that I posted?


the one I posted

New Question: Loops?

PostPosted: Sat Sep 26, 2009 9:23 pm
by Grenade1950
How do you make loops, like repeating the same thing over and over again until a condition is met?

Re: New Question: Loops?

PostPosted: Sat Sep 26, 2009 10:28 pm
by Fujitsu
Grenade1950 wrote:How do you make loops, like repeating the same thing over and over again until a condition is met?


You mean like this?

Rating: rated 5
Filesize: 13.64 kB
Comments: 0
Ratings: 1
download


There's a bug with Algodoo, so when you load the scene, select the box that says "Scene.my.A doesn't equal 5" and change it's text colour in the script menu to {Scene.my.D}.

Re: Loops?

PostPosted: Sun Sep 27, 2009 2:02 pm
by RA2lover
my custon kalashnikov - fires untill ammo runs out, using thyme
Rating: rated 7.6
Filesize: 334.89 kB
Comments: 20
Ratings: 11
download


e.normal is backwards on this one, so i think it shouldn't workproperly, being more of a suicide rifle

Re: Loops?

PostPosted: Sun Sep 27, 2009 2:36 pm
by KarateBrot
RA2lover wrote:e.normal is backwards on this one, so i think it shouldn't workproperly, being more of a suicide rifle


use (-1)*e.normal instead of e.normal if it's backwards so e.normal will be flipped about 180°

Re: Loops?

PostPosted: Sun Sep 27, 2009 8:32 pm
by Grenade1950
Could you post a script where it loops a variable until it hits 5? The script, not the scene... Thanks :D

And another thing: I have Phun, not Algodoo... :(

Re: Loops?

PostPosted: Sun Sep 27, 2009 8:42 pm
by KarateBrot
Grenade1950 wrote:And another thing: I have Phun, not Algodoo... :(

that shouldn't be a matter ;)

object 1
Code: Select all
scene.my.var < 5 ? {do something before 5 is reached} : {do something else when 5 is reached}


and another onCollide could be:

object 2
Code: Select all
scene.my.var = scene.my.var + 1


so now something at object 1 will always be repeated at a collision until object 2 has 5 collisions. after that object 1 will do something else at a collision.

Re: Loops?

PostPosted: Sun Sep 27, 2009 8:56 pm
by Fujitsu
Grenade1950 wrote:Could you post a script where it loops a variable until it hits 5? The script, not the scene... Thanks :D

And another thing: I have Phun, not Algodoo... :(


Oh, haha sorry.

Is this any better?

Rating: rated 5
Filesize: 13.64 kB
Comments: 0
Ratings: 1
download


All it really is, is an if statement that is asked ~every tick. It's much more accurate with a laser, you know! :D

Code: Select all
{Scene.my.A == 5} ? {         Scene.my.B = [0.425, 0.262, 0.0, 0.0];         Scene.my.D = [1.0, 1.0, 1.0, 0.0];         Scene.my.c = false     } : {}


Scene.my.A is the counter.
Scene.my.B and D make the "Scene.my.A doesn't equal 5" box disappear.
Scene.my.C stops the motor from counting more.