1
0

GT.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. setup.qsp_gt = function(...args){
  2. const _recursion_limit = 5;
  3. setup.recursionCounterGT ??= [0,0];
  4. const recursionInterval = Math.floor(Date.now() / 500);
  5. if(setup.recursionCounterGT[0] < recursionInterval)
  6. setup.recursionCounterGT = [recursionInterval,0];
  7. setup.recursionCounterGT[1] += 1;
  8. if(setup.recursionCounterGT[1] > _recursion_limit){
  9. console.error('Recursion limit reached in GT: (args, here)',args,State.variables.here);
  10. return;
  11. }
  12. let destination = '';
  13. let destinationArgs = [];
  14. if(typeof args[0] == 'string'){
  15. destination = args[0];
  16. destinationArgs = args.slice(1);
  17. }else if(Array.isArray(args[0])){
  18. destination = args[0][0];
  19. destinationArgs = args[0].slice(1);
  20. }else{
  21. console.error(`Argument not reckognized in setup.gt()`,args[0]);
  22. }
  23. State.variables.ARGSstack = [destinationArgs];
  24. console.log("GT",args,destination,destinationArgs,State.variables.ARGSstack);
  25. //$.wiki(`<<goto '${destination.toLowerCase()}'>>`);
  26. Engine.play(destination.toLowerCase());
  27. }
  28. Macro.add('gt', {
  29. skipArgs : false,
  30. handler : function () {
  31. try{
  32. setup.gt(...this.args);
  33. }
  34. catch (ex) {
  35. return this.error('ERROR in gt-widget: ' + ex.message);
  36. }
  37. }
  38. });