NEED help understanding thyme scripting

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

NEED help understanding thyme scripting

Postby 13yrmadman » Mon Jan 04, 2010 12:16 am

I dont get spawning objects or controlleracc. nor do i get variables
Or even what it does. could someone please help me.
ive already looked in gradyfitz thyme scripting posts.
please put it in simple terms
Alpha, Zeta, Eta, Theta, Iota to Omega
Thats Physics for you
User avatar
13yrmadman
 
Posts: 17
Joined: Sun Oct 04, 2009 3:35 am
Location: America

Re: NEED help understanding thyme scripting

Postby standardtoaster » Mon Jan 04, 2010 1:12 am

Here's an easy way to understand spawning. Scene.addCircle/Box/Polygon adds the object to the scene. The prefix "Scene" tells the code that it is going to be running one of the commands that is listed under Scene->. So, Scene.addCircle tells it to add a circle into the Scene. If you'll notice, Scene.addCircle adds it to the scene because it is under Scene.add... Same thing goes for Box and Polygon. You can spawn a lot of other things but it's a bit more complicated. The variable "controllerAcc" is the controller acceleration value under geometry controller. Most people use the controllerAcc as a placeholder for values that are constantly being called upon because it is either easier for them to do it that way, they don't want to make a variable for something simple like that, or any other reason. You can use lots of other things in an object to store things. To find only a certain part of a list use "insertvariable"(0) to get the first value, 1 to get the second value, etc.

Things in an object that you can use to store values
Integers/Floats
  • airFrictionMult
  • attraction
  • collideSet
  • color(you have a list here. it has four places to store values.)
  • controllerAcc
  • density
  • friction
  • materialVelocity(I wouldn't suggest this because it will make the object move, unless, of course you want it to. :P)
  • refractiveIndex
  • restitution
  • textColor(only if it is a box. This one is just like color.)
  • textureMatrix(this is a big one. You have nine placeholders to use. Keep in mind that if you have a texture on the object it will be changed drastically when you change these.)

Booleans(True/False)
  • controllerInvertX
  • controllerInvertY
  • controllerReverseXY
  • drawBorder
  • drawCake(only if it is a circle)
  • heteroCollide(no self-collision)
  • immortal
  • killer
  • opaqueBorders
  • protractor(only if it is a circle)
  • ruler(only if it is a box)

Strings(Text)
  • text(only if it is a box)

Now then, on to variables. Variables can be thought of things that you can manipulate just like you can an object. Variables can be integers, floats, lists, booleans, or strings. They can be a bit better to manipulate because you won't need to be constantly touching the object you want to affect. You could use a variable to store the position of an object, store the color of an object, continually do math, almost anything is possible. :D You can also use variables to make functions. A function will take however many inputs you made in the code and then "spit" back the answer. You could use a function to solve the distance between two points, the angle of an object, make a tan line, etc. I'll give an example. Suppose we want to make a tan line with a constant X value.
Code: Select all
Scene.my.TanLine=(n)=>{for(n, (y)=>{math.tan(y)})}

This will take "n," which is the number of times we want this to loop. The higher the number the more accurate it will be. Keep in mind that Algodoo/Phun will limit you if it gets to high. For is what is used to loop. For is a function. It works like this, For(n, what). N is the number of times to loop and "what" is what should happen during the loop. Math.tan is the tan function. If you execute this function in the console it will only tell you one number. To make sure that it is giving you what you want and to see it in work add this modification to it.
Code: Select all
Scene.my.TanLine=(n)=>{for(n, (y)=>{math.tan(y); console.print("X: " + math.tan(y))})}

I added console.print which will print whatever is in the parentheses, as long as it is a string, whether it be text or a calculation.

Any other questions or clarification I can do?
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: NEED help understanding thyme scripting

Postby Mystery » Mon Jan 04, 2010 1:22 am

Mines More user friendly (No big words either)
I'll start with variables
You need to have advanced mode ON open up the console ~ and type in
Code: Select all
Scene.my.test = 1

Scene.my.test act like a letter in Algebra. If you were to put {scene.my.test} into a shape Algodoo would read it as 1 it wouldn't even see the variable there. To change a variable oncollide it's a bit tricky
Code: Select all
scene.my.test = scene.my.test = 2
scene.my.test is repeated twice (make a little more sense when you do advanced stuff)
Let have an example of this i have a ball every time it bounces i want it to get heavier
Open up the console ~
Code: Select all
scene.my.density = 2

open up the square
in density type in
Code: Select all
{scene.my.density}
In oncollide Type in
Code: Select all
{Scene.my.density = scene.my.density + 1}


Controlleracc is the ability to make thing move with the mouse keys since it fairly shitty no one uses it instead we use it as a blank variable. To record how many times a ball has bounced we would make controlleracc go up once each time oncollide.

I would love to tell you how to spawn stuff but it's already been done viewtopic.php?f=14&t=599
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 24 guests

cron