|
| 07 Oct 2011 02:02 PM |
if script.Parent.localdir.Value*22.5*math.pi/180 - game.Workspace.Vars.wdir.Value*22.5*math.pi/180 <= (56.25*math.pi/180) or script.Parent.localdir.Value*22.5*math.pi/180 - game.Workspace.Vars.wdir.Value*22.5*math.pi/180 >= (-56.25*math.pi/180) then print 'working' end
localdir.Value and wdir.Value are both integers, 0 to 15
This script is supposed to determine whether or not localdir is within 56.25 degrees of wdir, but it is just printing 'working' all the time
(I would use a .magnitude instead of the two <= and >= comparisons, but it isn't accepting number values in the magnitude method) |
|
|
| Report Abuse |
|
|
|
| 07 Oct 2011 02:19 PM |
| To complex for the forums? |
|
|
| Report Abuse |
|
|
1WOOF1
|
  |
| Joined: 03 May 2009 |
| Total Posts: 20682 |
|
| |
|
|
| 07 Oct 2011 02:26 PM |
| Never mind I figured out a better way to do this |
|
|
| Report Abuse |
|
|
|
| 07 Oct 2011 02:30 PM |
| Nope that's a lie the new way won't work. Original question? |
|
|
| Report Abuse |
|
|
|
| 07 Oct 2011 02:54 PM |
Let me try to rephrase if this is too much... I have two integers, that can be anywhere from 0 to 15
Now, I need to find out if these two numbers are within 3 numbers of each other Example: if a=8 and b=6, then yes their magnitude is less than or equal to 3
However, 15 is one number away from 0. This is why I need to convert them to radians |
|
|
| Report Abuse |
|
|
myrco1001
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 2574 |
|
|
| 07 Oct 2011 03:11 PM |
You need spaces, so like:
Value * 28
-♂ MYRCO♂- Scripter, music obsessed, atheist and dutch. What else? |
|
|
| Report Abuse |
|
|
|
| 07 Oct 2011 03:30 PM |
The spaces aren't the problem.
I found out a solution from a chat room online though.
There's an operator called mod, or % that can be used in situations like these, if anyone is interested |
|
|
| Report Abuse |
|
|
myrco1001
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 2574 |
|
|
| 07 Oct 2011 03:42 PM |
I didn't even read the full post anyways. And % is module yes, it works like this:
function %(x, y) if x - y < 0 then return 0 end repeat x = x - y until x - y < y return x end
-♂ MYRCO♂- Scripter, music obsessed, atheist and dutch. What else? |
|
|
| Report Abuse |
|
|