Page 1 of 1

Script bug

PostPosted: Fri Feb 26, 2010 1:16 am
by Mr_Stabby
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

Re: Script bug

PostPosted: Fri Feb 26, 2010 1:23 am
by KarateBrot
Why don't you just use e.normal to measure the angle? you will only need 1 laser for it and a small code.

Re: Script bug

PostPosted: Fri Feb 26, 2010 1:33 am
by Mr_Stabby
ah wasnt aware of the e.normal attributes, that works too ty

Re: Script bug

PostPosted: Fri Feb 26, 2010 1:38 am
by KarateBrot
:thumbup:
you can use trigonometric functions to get the angle from it. if you already knew this how did you make it otherwise?