Uneven relative movement on a grid - Need some help

So I think I have a script for you. I'm not sure because I can't test it within context of your game for obvious reasons.

If you want to move forward 4 steps and left 2, use it like so: move_direction( 4, 0, 0, 2 ); It just uses a repeat loop for each cardinal direction and sets the variable _okay to false if it hits a wall, at which point the x and y values are returned to their previous coords and the script returns false. Otherwise the script will move the player and will return true if successful.

/// move_direction ( forward, backward, right, left );

var _forward, _backward, _right, _left;
var _x, _y, _okay;

_forward = argument0;
_back    = argument1;
_right   = argument2;
_left    = argument3;
_x = x;
_y = y;
_okay = true;

repeat(_forward)
{
    if pm_SpaceFree(image_angle) {
        x += lengthdir_x(GridX, image_angle);
        y += lengthdir_y(GridY, image_angle);
    }
    else _okay = false;
}
if _okay
repeat(_back)
{
    if pm_SpaceFree(image_angle + 180) {
        x += lengthdir_x(GridX, image_angle + 180);
        y += lengthdir_y(GridY, image_angle + 180);
    }
    else _okay = false;
}
if _okay
repeat(_right)
{
    if pm_SpaceFree(image_angle + 90) {
        x += lengthdir_x(GridX, image_angle + 90);
        y += lengthdir_y(GridY, image_angle + 90);
    }
    else _okay = false;
}
if _okay
repeat(_left)
{
    if pm_SpaceFree(image_angle - 90) {
        x += lengthdir_x(GridX, image_angle - 90);
        y += lengthdir_y(GridY, image_angle - 90);
    }
    else _okay = false;
}

if !_okay
{
    x = _x;
    y = _y;
    return false;
}
else
    return true;
/r/gamemaker Thread