Script bug

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

Script bug

Postby Mr_Stabby » Fri Feb 26, 2010 1:16 am

I made an angle calculating formula based off 2 lasers hitting a box from either side, the box has 3 lasers pointed at it (2 for measuring angle 1 for spawning) and it can tell the difference between them, the problem is that this particular part of the script doesent really work


Code: Select all
xdiff = textcolor(2) - textcolor(0);
ydiff = textcolor(1) - textcolor(3);         
scene.my.var = anglez;       
xdiff > 0 ?
   {             ydiff = ydiff + 0.03125;             anglez = ydiff / 0.0625 * 180 - 90         } :
   {             ydiff = ydiff + 0.03125;             anglez = 270 - ydiff / 0.0625 * 180         };


it goes through the part and in the end has no idea what anglez is, if i put scene.my.var=anglez inside the brackets it works perfectly but anything thats outside that if statement cant get access to anglez variable, this is driving me nuts since i dont see anything wrong with it
Mr_Stabby
 
Posts: 155
Joined: Wed Dec 16, 2009 12:16 am

Re: Script bug

Postby KarateBrot » Fri Feb 26, 2010 1:23 am

Why don't you just use e.normal to measure the angle? you will only need 1 laser for it and a small code.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Script bug

Postby Mr_Stabby » Fri Feb 26, 2010 1:33 am

ah wasnt aware of the e.normal attributes, that works too ty
Mr_Stabby
 
Posts: 155
Joined: Wed Dec 16, 2009 12:16 am

Re: Script bug

Postby KarateBrot » Fri Feb 26, 2010 1:38 am

:thumbup:
you can use trigonometric functions to get the angle from it. if you already knew this how did you make it otherwise?
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron