Advertisement
ezmash

Jump To Label (MV)

Jan 14th, 2018
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2.  * JumpToLabel by Shaz
  3.  * Ver 1.00 2018.01.14
  4.  * Shaz_JumpToLabel.js
  5.  *
  6.  *
  7.  * @plugindesc More flexible Jump to Label command.
  8.  * @author Shaz
  9.  *
  10.  * @param Ignore Case
  11.  * @desc Ignore case when searching for label.
  12.  * @type boolean
  13.  * @default true
  14.  *
  15.  * @help This plugin allows you to use dynamic Jump to Label commands, where
  16.  * the 'destination' is a formula.
  17.  *
  18.  * Plugin Commands:
  19.  * JumpToLabel dest
  20.  *
  21.  * Example:
  22.  * JumpToLabel this._mapId
  23.  * JumpToLabel $gameVariables.value(7)
  24.  * JumpToLabel 'Talk to ' + $gameParty.leader().name()
  25.  *
  26.  *
  27.  * NOTE:
  28.  * If the label cannot be found in the current event, it will continue
  29.  * processing following the JumpToLabel plugin command.  It may be wise to
  30.  * add an Exit Event Processing command afterwards.
  31.  *
  32.  */
  33.  
  34. var Imported = Imported || {};
  35. Imported.Shaz_JumpToLabel = true;
  36.  
  37. var Shaz = Shaz || {};
  38. Shaz.JL = Shaz.JL || {};
  39. Shaz.JL.Version = 1.00;
  40.  
  41. Shaz.Parameters = PluginManager.parameters('Shaz_JumpToLabel');
  42. Shaz.Param = Shaz.Param || {};
  43. Shaz.Param.JL = Shaz.Param.JL || {};
  44.  
  45. Shaz.Param.JL.IgnoreCase = eval(Shaz.Parameters['Ignore Case']);
  46.  
  47. (function() {
  48.     var _Shaz_JL_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  49.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  50.         switch(command.toUpperCase()) {
  51.             case 'JUMPTOLABEL':
  52.                 var labelName = eval(args.join(' '));
  53.                 for (var i = 0; i < this._list.length; i++) {
  54.                     var command = this._list[i];
  55.                     if (command.code === 118 && (command.parameters[0] === labelName || (Shaz.Param.JL.IgnoreCase && String(command.parameters[0]).toUpperCase() === String(labelName).toUpperCase()))) {
  56.                         this.jumpTo(i);
  57.                         return;
  58.                     }
  59.                 }
  60.                 break;
  61.             default:
  62.                 _Shaz_JL_Game_Interpreter_pluginCommand.call(this, command, args);
  63.         }
  64.     };
  65.  
  66. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement