Loops?

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

Loops?

Postby Grenade1950 » Sat Sep 26, 2009 2:51 pm

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...
Last edited by Grenade1950 on Sat Sep 26, 2009 9:25 pm, edited 1 time in total.
Grenade1950
 
Posts: 9
Joined: Sat Sep 26, 2009 2:40 pm

Re: Liquify if not immortal?

Postby standardtoaster » Sat Sep 26, 2009 3:07 pm

Code: Select all
e.other.immortal == true ? {e.other.liquify} : {}
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Liquify if not immortal?

Postby Grenade1950 » Sat Sep 26, 2009 3:11 pm

That didn't work... Also, I want it to liquify if NOT immortal
Grenade1950
 
Posts: 9
Joined: Sat Sep 26, 2009 2:40 pm

Re: Liquify if not immortal?

Postby Grenade1950 » Sat Sep 26, 2009 3:21 pm

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:
Last edited by Grenade1950 on Sat Sep 26, 2009 3:51 pm, edited 1 time in total.
Grenade1950
 
Posts: 9
Joined: Sat Sep 26, 2009 2:40 pm

Re: Liquify if not immortal?

Postby standardtoaster » Sat Sep 26, 2009 3:50 pm

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.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Liquify if not immortal?

Postby Grenade1950 » Sat Sep 26, 2009 3:52 pm

Code: Select all
e.other.immortal ? {} : {e.other.liquify}


This should liquify whatever it touches if it's NOT immortal
Grenade1950
 
Posts: 9
Joined: Sat Sep 26, 2009 2:40 pm

Re: Liquify if not immortal?

Postby Grenade1950 » Sat Sep 26, 2009 5:09 pm

Hmm. I ungrouped the circles and it seems to work now...?
Grenade1950
 
Posts: 9
Joined: Sat Sep 26, 2009 2:40 pm

Re: Liquify if not immortal?

Postby standardtoaster » Sat Sep 26, 2009 5:12 pm

Are you talking about the script that you posted or the one that I posted?
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Liquify if not immortal?

Postby Grenade1950 » Sat Sep 26, 2009 5:16 pm

standardtoaster wrote:Are you talking about the script that you posted or the one that I posted?


the one I posted
Grenade1950
 
Posts: 9
Joined: Sat Sep 26, 2009 2:40 pm

New Question: Loops?

Postby Grenade1950 » Sat Sep 26, 2009 9:23 pm

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

Re: New Question: Loops?

Postby Fujitsu » Sat Sep 26, 2009 10:28 pm

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}.
Image
Gimmie money.
User avatar
Fujitsu
 
Posts: 328
Joined: Tue Sep 01, 2009 12:28 am
Location: Canada

Re: Loops?

Postby RA2lover » Sun Sep 27, 2009 2:02 pm

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
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: Loops?

Postby KarateBrot » Sun Sep 27, 2009 2:36 pm

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°
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Loops?

Postby Grenade1950 » Sun Sep 27, 2009 8:32 pm

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... :(
Grenade1950
 
Posts: 9
Joined: Sat Sep 26, 2009 2:40 pm

Re: Loops?

Postby KarateBrot » Sun Sep 27, 2009 8:42 pm

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.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Loops?

Postby Fujitsu » Sun Sep 27, 2009 8:56 pm

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.
Image
Gimmie money.
User avatar
Fujitsu
 
Posts: 328
Joined: Tue Sep 01, 2009 12:28 am
Location: Canada


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests

cron