Square Root Thyme Function/Script

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

Square Root Thyme Function/Script

Postby BAZOOKA » Thu Apr 11, 2013 3:20 pm

I would like to ask for the function of square rooting a number in thyme, as i am about to make a speed reader with the speed of the x-axis and the y-axis.
I would also like to ask if there is a thyme script called (readable(e.geom)).vel(0) and (readable(e.geom)).vel(1) like app.mousepos(0) and app.mousepos(1)
Some science teacher said one day,'Remember to leave the water dry...'
User avatar
BAZOOKA
 
Posts: 22
Joined: Fri Oct 26, 2012 5:45 pm

Re: Square Root Thyme Function/Script

Postby monstertje3 » Thu Apr 11, 2013 3:40 pm

use x^0.5
or Math.sqrt(x)
where x is your variable
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: Square Root Thyme Function/Script

Postby BAZOOKA » Fri Apr 12, 2013 2:19 pm

Thanks! I'll try it out.
How about the position thing?
Some science teacher said one day,'Remember to leave the water dry...'
User avatar
BAZOOKA
 
Posts: 22
Joined: Fri Oct 26, 2012 5:45 pm

Re: Square Root Thyme Function/Script

Postby BAZOOKA » Fri Apr 12, 2013 2:26 pm

Hey, this is weird.
I used both the functions:
onHitByLaser:
Code: Select all
{scene.my.a ^ 0.5}

and:
Code: Select all
{Math.sqrt(scene.my.a)

but neither worked! What is going on?! :?
Some science teacher said one day,'Remember to leave the water dry...'
User avatar
BAZOOKA
 
Posts: 22
Joined: Fri Oct 26, 2012 5:45 pm

Re: Square Root Thyme Function/Script

Postby monstertje3 » Fri Apr 12, 2013 2:52 pm

When i put this in the console
Code: Select all
scene.my.var:=16


and put
Code: Select all
{[scene.my.var^0.5,2]}

in size, i get [4,2] (observed)

if i put
Code: Select all
scene.my.var=4

in the console i get a square. (geom resizes)
so it works with me (2.1.0 b12)
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: Square Root Thyme Function/Script

Postby carl00s01 » Sat Apr 13, 2013 4:09 am

The function on 2.1.0 b12 does the job.
Code: Select all
math.vec.len(x)
User avatar
carl00s01
 
Posts: 24
Joined: Fri Nov 26, 2010 7:03 pm
Location: Brazil

Re: Square Root Thyme Function/Script

Postby BAZOOKA » Sun Apr 14, 2013 4:20 pm

hey people...i use v2.0.1...and i think the v2.0.2 b4 and v2.1.0 b12 are rather unreliable, so i still use v2.0.1. so what's the function for that?
Some science teacher said one day,'Remember to leave the water dry...'
User avatar
BAZOOKA
 
Posts: 22
Joined: Fri Oct 26, 2012 5:45 pm

Re: Square Root Thyme Function/Script

Postby monstertje3 » Sun Apr 14, 2013 4:36 pm

The functions i said are in from the first algodoo versions (possibly even phun for Math.sqrt()), so you should have them, you probably typed incorectly or didn't declare the variable.
Upload the scene to algobox and show it here so we can see the problem and help you.
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: Square Root Thyme Function/Script

Postby BAZOOKA » Mon Apr 15, 2013 4:49 pm

yeah sure...here it is.
oh damn. how to I put the scene up her?!! :wtf: :wtf: :wtf:
Some science teacher said one day,'Remember to leave the water dry...'
User avatar
BAZOOKA
 
Posts: 22
Joined: Fri Oct 26, 2012 5:45 pm

Re: Square Root Thyme Function/Script

Postby BAZOOKA » Mon Apr 15, 2013 4:53 pm

wait. here it is
Rating: rated 5
Filesize: 4.12 kB
Comments: 3
Ratings: 1
download
Some science teacher said one day,'Remember to leave the water dry...'
User avatar
BAZOOKA
 
Posts: 22
Joined: Fri Oct 26, 2012 5:45 pm

Re: Square Root Thyme Function/Script

Postby monstertje3 » Mon Apr 15, 2013 5:06 pm

Code: Select all
(e)=>{
    Math.sqrt(scene.my.a)
}


I can make from this that you are trying to use the square root every collide, however your problem is that nothing actually saves. You have to say x=y, now you do y, where y just stays y and doesn't change. Try the next code:

Code: Select all
(e)=>{
    scene.my.a=Math.sqrt(scene.my.a)
}


Now every collision scene.my.a gets saved as Math.sqrt(scene.my.a) resulting in the root of scene.my.a (after some collisions it should come near to 0)
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: Square Root Thyme Function/Script

Postby BAZOOKA » Sat Apr 20, 2013 6:01 pm

ahh...i've updated to version 2.1.0, so i'll check:
Code: Select all
math.vec.len(x)

if you have any alternatives, do say about them!
Some science teacher said one day,'Remember to leave the water dry...'
User avatar
BAZOOKA
 
Posts: 22
Joined: Fri Oct 26, 2012 5:45 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests