setup.gt = function(...args){
	const _recursion_limit = 5;

	setup.recursionCounterGT ??= [0,0];
	const recursionInterval = Math.floor(Date.now() / 500);
	if(setup.recursionCounterGT[0] < recursionInterval)
		setup.recursionCounterGT = [recursionInterval,0];
	setup.recursionCounterGT[1] += 1;
	if(setup.recursionCounterGT[1] > _recursion_limit){
		console.error('Recursion limit reached in GT: (args, here)',args,State.variables.here);
		return;
	}



	/*let destination:string|Location;
	let args:any[]=[];

	console.warn(arg);

	if(arg[0] instanceof setup.LocationIdentifier){
		destination = arg[0].passage;
		args = [destination,...(arg[0].passageArguments)];
	}else{
		if(Array.isArray(arg[0]))
			args = arg[0];
		else if(Array.isArray(arg[1]))
			args = [arg[0],...(arg[1])]
		else
			args = arg;

		destination = args[0];
	}

	if(destination instanceof setup.Location)
		destination = destination.passage;
	destination = destination as string;*/
	/**
	 * The title of the destination passage
	 * @type {string}
	 */
	let destination:string = '';
	let destinationArgs:string[] = [];
	
	if(typeof args[0] == 'string'){
		destination = args[0];
		destinationArgs = args.slice(1);
	}else if(args[0] instanceof setup.LocationIdentifier){
		destination = args[0].passage;
		destinationArgs = args[0].passageArguments;
	}else if(args[0] instanceof setup.Location){
		destination = args[0].locationIdentifier.passage;
		destinationArgs = args[0].locationIdentifier.passageArguments;
	}else if(Array.isArray(args[0])){
		destination = args[0][0];
		destinationArgs = args[0].slice(1);
	}else{
		console.error(`Argument not reckognized in setup.gt()`,args[0]);
	}


	State.variables.location_var = {};
	State.variables.location_var[destination] = [];

	State.variables.location_var[destination] = destinationArgs;

	console.log("GT: "+destination,State.variables.location_var[destination],"FROM:"+State.variables.here);

	$.wiki(`<<goto '${destination}'>>`);
	
}

Macro.add('gt', {
	skipArgs : false,
	handler  : function () {
		try{
			setup.gt(...this.args);
		}
		catch (ex) {
			return this.error('ERROR in gt-widget: ' + ex.message);
		}
	}
});
