New Speedwalk function
Posted: Mon Jul 16, 2012 10:52 pm
While helping Rydekull with an adaptation of the speedwalk function, I decided to flesh it out and offer it up for anyone interested.
As you can see, in order to handle diagonals, you need to pass them in []'s. You can add anything you'd like to the reverse_table (like in = "out") and commands will be reversed.
The only real addition to the current, built-in speedwalk function is the ability to pass arbitrary commands. It loses some input flexibility, however.
This can easily be adapted to handle any sort of activity, not just walking.
Paths are a single string. No spaces or commas or anything. For instance, this was my test string: "2s[nw]3e[jump][hop]4e[row the boat 10 times]2wn[se]". Basically, any cardinal direction (n, e, s, w, d, u) is passed as a single character. Commands are passed in brackets. Optionally, you can prepend a number to any command to have it repeated that many times.
As you can see, in order to handle diagonals, you need to pass them in []'s. You can add anything you'd like to the reverse_table (like in = "out") and commands will be reversed.
The only real addition to the current, built-in speedwalk function is the ability to pass arbitrary commands. It loses some input flexibility, however.
This can easily be adapted to handle any sort of activity, not just walking.