Basic SCripting Tutorial

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

Basic SCripting Tutorial

Postby mold999 » Wed Mar 02, 2011 4:42 am

This is basically what the title says. I will explain some of the variable/OnCollide scripting.

I will list the steps, and explain them as I go.

1.) Open up the console in Algodoo (Phun) using F11 or 'tilde' (~)

2.) Type scene.my.Write your variable here, and then have it equal some value (i.e. 10, .4, true). It should look something like this :
Code: Select all
scene.my.dens = 100


3.) Open the script menu of an object, and type your variable (including the scene.my.) into any box. Be sure yo put curly brackets { } around the ENTIRE variable. DO NOT include the value of the variable. It should look something like this :
Code: Select all
{scene.my.dens}
. If I inputted this into the density box, Now, the object you have selected will have the density of the value you inputted for the variable. So, if I had my variable's value at 5, the density of the selected object will be five.

4.) To change the density of this object (object A, I'll call it) when another object collides, open the script menu of another object (object B), and paste this into the OnCollide box :
Code: Select all
scene.my.dens = scene.my.dens = 10
This will change the density of the original object to 10. (Please not that object B DOES NOT have to collide with object A in order for the script to work. Object B CAN COLLIDE WITH ANY OTHER OBJECT!)

5.) You can also increase the density object A, so that every time object B collides, it increases the density of object A by one (this can also be inputted into the OnCollide of object A). The code looks like this :
Code: Select all
scene.my.dens = scene.my.dens + 1


6.) If you want to change the color of object A, you do not secondarily need any variables (only if you want when object B collides, it changes the color of object A). Input this into the OnCollide of object A :
Code: Select all
e.this.color = [1, 1, 1, 1]
this will change the color of object A white.


This concludes my basic scripting tutorial. If you have any questions or comments, PM me or add a reply to this scene.

I will add another slightly more advanced tutorial, but right now I'm too lazy.
Last edited by mold999 on Wed Mar 02, 2011 11:12 pm, edited 1 time in total.
Phundementalism?

Ain't nobody got
thyme fo dat.
User avatar
mold999
 
Posts: 225
Joined: Sun Jan 02, 2011 1:35 am
Location: [176436, 3763234]

Re: Basic SCripting Tutorial

Postby frogman786 » Wed Mar 02, 2011 7:48 am

thanks i've been looking for something like this for awhile
im pretty sure for number 6 to change the color you don't need to put
Code: Select all
e.this.color = [1,1,1,1]
just put
Code: Select all
color = [1,1,1,1]
DFTBA nerdfighters

TheWonkits wrote:As immature as some of the people on this forum can be, most of you are pretty cool.

TC42 wrote:Better than spell-check... ...TC42's instant grammar-correction posts! :lol:
User avatar
frogman786
 
Posts: 71
Joined: Fri Jan 07, 2011 8:32 am
Location: Christchurch, New Zealand

Re: Basic SCripting Tutorial

Postby mold999 » Wed Mar 02, 2011 11:05 pm

frogman786 wrote:thanks i've been looking for something like this for awhile
im pretty sure for number 6 to change the color you don't need to put
Code: Select all
e.this.color = [1,1,1,1]
just put
Code: Select all
color = [1,1,1,1]


I know, but I think that the e.this. clarifies that you can do an e.other. also.
Phundementalism?

Ain't nobody got
thyme fo dat.
User avatar
mold999
 
Posts: 225
Joined: Sun Jan 02, 2011 1:35 am
Location: [176436, 3763234]

Re: Basic SCripting Tutorial

Postby frogman786 » Thu Mar 03, 2011 12:38 am

yea explaining things like e.other, e.this and e.geom would help noobs in the long run (just suggesting it)

oh and nuber 4 looks like you made a mistake
Code: Select all
scene,.my.dens = scene.my.dens = 10
DFTBA nerdfighters

TheWonkits wrote:As immature as some of the people on this forum can be, most of you are pretty cool.

TC42 wrote:Better than spell-check... ...TC42's instant grammar-correction posts! :lol:
User avatar
frogman786
 
Posts: 71
Joined: Fri Jan 07, 2011 8:32 am
Location: Christchurch, New Zealand

Re: Basic SCripting Tutorial

Postby mold999 » Thu Mar 03, 2011 1:08 am

I fail...
Phundementalism?

Ain't nobody got
thyme fo dat.
User avatar
mold999
 
Posts: 225
Joined: Sun Jan 02, 2011 1:35 am
Location: [176436, 3763234]

Re: Basic SCripting Tutorial

Postby Dare » Thu Mar 03, 2011 12:42 pm

Did you search around?
I'm sorry, but this thread is simply a waste of space. It has already been done, and it's been done better by a more experienced thyme mechanic.
ImageImage
TC42 wrote:Dare, you are creepy.

Official Algobox Admin! Please PM me if you have any issues regarding Algobox.
User avatar
Dare
 
Posts: 833
Joined: Sat Nov 21, 2009 4:27 pm
Location: Sydney, Australia

Re: Basic SCripting Tutorial

Postby TC42 » Thu Mar 03, 2011 10:25 pm

This link is even stickied! How did you not see it? :|

Also, you forgot to mention if statements, the most useful thing in scripting.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Basic SCripting Tutorial

Postby mold999 » Thu Mar 03, 2011 10:36 pm

Look, the new people who come here might not even know what to look for. If this thread is new, it will be on the front page, so the new people will look at this, and know there is more to search for.
Phundementalism?

Ain't nobody got
thyme fo dat.
User avatar
mold999
 
Posts: 225
Joined: Sun Jan 02, 2011 1:35 am
Location: [176436, 3763234]

Re: Basic SCripting Tutorial

Postby Dare » Thu Mar 03, 2011 11:09 pm

ImageImage
TC42 wrote:Dare, you are creepy.

Official Algobox Admin! Please PM me if you have any issues regarding Algobox.
User avatar
Dare
 
Posts: 833
Joined: Sat Nov 21, 2009 4:27 pm
Location: Sydney, Australia


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest