I'm trying to cut some corners and have something assign a dir to itself (thereby choosing the appropriate icon) by simply comparing its position.
Unfortunately, I'm discovering that the moment the thing is not in one of the four cardinal directions, get_dir spazzes out and hands it a diagonal.
I seem to recall seeing somewhere there's a more precise version of get_dir, but I haven't managed to locate it. Outside of remembering how to properly manipulate a slope again (probably feeding the slope into switch to return the answer), does anyone happen to have a nice surrogate get_dir laying around?
ID:158517
![]() Aug 12 2009, 3:20 pm
|
|
![]() Aug 12 2009, 3:23 pm
|
|
hub://Nadrew.rangedetection has an advanced get_dir proc that gets more precise directions.
|
Found it. Well designed too. Thanks, Nadrew (and by extension, Lummox for the original code).'
Funny enough, I ran into the same problem even with get_dir that uses an arctan calculated angle to pull it off. Given that the direction looks longer, that a diagonal shows up is probably decimal points being lost during the calculations. |