:: MacroGT[widget]
<<widget 'gt'>>
    <<set _recursion_limit to 15>>

    <<if _args[0] instanceof setup.LocationIdentifier>>
		<<set _destintation = _args[0].passage>>
		<<set _args = [_destintation,...(_args[0].passageArguments)]>>
    <<else>>
		<<if Array.isArray(_args[0])>>
			<<set _args = _args[0]>>
		<</if>>
        <<if Array.isArray(_args[1])>>
            <<set _args = [_args[0],...(_args[1])]>>
        <</if>>

		<<set _destintation = _args[0]>>
	<</if>>

    <<if _destintation instanceof setup.Location>><<set _destintation = _destintation.passage>><</if>>

    <<if !$gt_history>>
        <<set $gt_history to {}>>
    <</if>>
    <<set _ts to Math.floor(Date.now() / 10000)>>
    <<if !$gt_history[_ts]>>
        <<set $gt_history[_ts] to {}>>
    <</if>>
    <<if !$gt_history[_ts][_destintation]>>
        <<set $gt_history[_ts][_destintation] to 0>>
    <</if>>
    <<set $gt_history[_ts][_destintation] += 1>>

    <<set _temp_history to {}>>
    <<for _time,_history range  $gt_history>>
        <<if _time > _ts - 10>>
            <<set _temp_history[_time] = _history>>
        <</if>>
    <</for>>
    <<set $gt_history to _temp_history>>

    <!--<<if !$location_var>>-->
        <<set $location_var to {}>>
    <!--<</if>>-->

    <<if !$location_var[_destintation]>>
        <<set $location_var[_destintation] to []>>
    <</if>>

    <<for _i = 1; _i < 10; _i++>>
        <<set $location_var[_destintation][(_i-1)] to _args[_i]>>
    <</for>>

    <<run console.log("GT: "+_args[0],$location_var[_destintation],$gt_history,"FROM:"+$here)>>

    <<if $gt_history[_ts][_destintation] <= _recursion_limit>>
        <<set $here = _destintation>>
        <<set $ARGS = $location_var[$here]>>
        <<set _terminateGS = true>>
        <<goto _destintation>>
    <<else>>
        <<run console.error('RECURSION LIMIT REACHED',_destintation,$gt_history)>>
    <</if>>
<</widget>>

<<widget 'xgt'>>
    <<gt _args[0] _args[1] _args[2] _args[3] _args[4] _args[6] _args[7] _args[8] _args[9] _args[10] _args[11]>>
<</widget>>

<<widget 'regt'>>
    <<gt $here $location_var[$here][0] $location_var[$here][1] $location_var[$here][2] $location_var[$here][3]>>
<</widget>>
