"Trusty" Vector collision code not working

Hi - I usually use this function to detect whether two vectors have crossed - but in haxe it’s no longer working.

Could any math boffin-types figure out why ? The s & t calculations have always foxed me, but they worked before and now that don’t ! Does haxe handle these kinds of calculations differently ?

// passes in 2 sets of co-rds for each vector ..
public static function collCheck(xp1:Float, xp2:Float, yp1:Float, yp2:Float, xp3:Float, xp4:Float, yp3:Float, yp4:Float) 
		var S1x = xp2-xp1;
		var S1y = yp2-yp1;
		var S2x = xp4-xp3;
		var S2y = yp4-yp3;
		var s = (-S1y*(xp1-xp3)+S1x*(yp1-yp3))/(-S2x*S1y+S1x*S2y);
		var t = (S2x*(yp1-yp3)-S2y*(xp1-xp3))/(-S2x*S1y+S1x*S2y);
		var retVal = -1;
		if ((s>0) && (s<1) && (t>0) && (t<1))
		// a collision between the two lines has occurred	
                var retVal = t;
		return retVal;

Maybe change

var retVal = t;


retVal = t;

This is because the var keyword is declaring a new variable instead of setting retVal. :smiley: