/// collision_line_first(x1, y1, x2, y2, obj, prec, notme)
// returns closest instance colliding with a line or noone. (closest by their origin position to (x1,y1))
var x1, y1, x2, y2, obj, prec, notme, inst, inst_dist, ans, ans_dist;
x1 = argument0;
y1 = argument1;
x2 = argument2;
y2 = argument3;
obj = argument4;
prec = argument5;
notme = argument6;
ans = noone;
for (var i = 0; i < instance_number(obj); i++)
{
inst = collision_line(x1,y1,x2,y2, instance_find(obj, i), prec, notme);
if (inst != noone)
{
if (ans != noone)
{
inst_dist = point_distance(x1, y1, ans.x, ans.y);
if (inst_dist < ans_dist)
{
ans = inst;
ans_dist = inst_dist;
}
}
else
{
ans = inst;
ans_dist = point_distance(x1, y1, ans.x, ans.y);
}
}
}
return ans;