let CSD = GetCurrentScriptDirectory;

function wait(howlong){
	loop( howlong ){
		yield;
	}
}

function GetDistance(x1, y1, x2, y2){
	return((( x2-x1 )^2+( y2-y1 )^2 )^( 1/2 ))
}

function AddToArray(Array,TargetIndex,Value,Type){ // From Ultima, thanks!!
        let temp = [];
       
        alternative(Type)
        case("APPEND")
        {
                ascent(i in 0..length(Array))
                {
                        if(i == TargetIndex)
                        {
                                temp = append(temp,Value);
                        }
               
                        temp = append(temp,Array[i]);
                }
        }
        case("CONCATENATE")
        {
                ascent(i in 0..length(Array))
                {
                        if(i == TargetIndex)
                        {
                                temp = concatenate(temp,Value);
                        }
               
                        temp = concatenate(temp,Array[i]);
                }
        }      
        others
        {
                RaiseError("Invalid Array Merge Type");
        }
        return temp
}

function sqrt(value){
	return value^0.5
}