Path Reversing Script
-
Hey y'all, I've found myself needing the ability to reverse a path, so I wrote a little script that I'd like to share!
-
Good, i comment small changes.
-
Thanks! Wasn't too sure what the best way to avoid the if was.
-
I found reversing directions handy in several circumstances. Now I wonder, on a larger scale, if an object lookup or a calculation is more CPU efficient...
function reverse(dir){return (dir + 3)%8+1;} reverse(LEFT); vs reverse:{TOP:BOTTOM,TOP_RIGHT:BOTTOM_LEFT,RIGHT:LEFT,BOTTOM_RIGHT:TOP_LEFT,BOTTOM:TOP,BOTTOM_LEFT:TOP_RIGHT,LEFT:RIGHT,TOP_LEFT:BOTTOM_RIGHT}; reverse[LEFT];
-
Good! Simple and useful!