I didn't write the pathfinding algorithm. I'm using Galv's code which is an edited version of the algorithm that comes with the program. You can take a look at it here:
(Download the plug-in file. Then look at
Game_Character.prototype.findDirectionTo = function(goalX, goalY) {
)