Guest User

Script call event syntax change

a guest
May 31st, 2016
10
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Astfgl's QOL script box improvements v0.1
  3. // by Astfgl
  4. // Date: 31/05/2016  
  5. // You are allowed to use this plugin free of charge, both for commercial and
  6. // non commercial use. If used in a commercial project, a free copy would be
  7. // nice, but is not required. You are freely allowed to edit this plugin, but
  8. // you must keep this header intact and readable. You are not allowed to
  9. // release anything using or based on this plugin without abiding by this
  10. // license. Your credits must include "Scriptbox QOL Improvements by Astfgl".
  11. //
  12. //
  13. // Credits: template made by Faytless / Thomas Pham. Without that, I
  14. // would still be making modification in the core files.
  15. //=============================================================================
  16.  
  17.  
  18. /*:
  19.  * @plugindesc QOL improvements for eventing
  20.  * @author Astfgl
  21.  *
  22.  * @param No params are available
  23.  * @desc -
  24.  * @default -  
  25.  
  26.  */
  27.  
  28.   (function() {
  29.   var parameters = PluginManager.parameters('Astgfl');
  30.  
  31.  
  32.  // Below i define all the functions that can be used while inside a script box
  33.  
  34.   var _Game_Interpreter_Astfgl = Game_Interpreter.prototype.command355;
  35.  
  36.   Game_Interpreter.prototype.command355 = function() {
  37.     var variableId, Index, value
  38.     var script = this.currentCommand().parameters[0] + '\n';
  39.     while (this.nextEventCode() === 655) {
  40.         this._index++;
  41.         script += this.currentCommand().parameters[0] + '\n';
  42.     }
  43.    
  44.     SV = function(variableId, value) {
  45.         var variableId, value
  46.         $gameVariables.setValue(variableId, value)
  47.     }
  48.    
  49.     SVA = function(variableId, index, value) {
  50.         var variableId, Index, value
  51.         $gameVariables.SVA(variableId, index, value)
  52.     }
  53.    
  54.     RV = function(variableId) {
  55.         var variableId
  56.         return $gameVariables.value(variableId)
  57.     }
  58.    
  59.     RVA = function(variableId, index) {
  60.         var variableId, index
  61.         return $gameVariables.RVA(variableId, index)
  62.     }
  63.    
  64.     SS = function(switchId, value) {
  65.         var switchId, value
  66.         $gameSwitches.setValue(switchId, value)
  67.     }
  68.    
  69.     RS = function(switchId){
  70.         var switchId
  71.         return $gameSwitches.value(switchId)
  72.     }
  73.    
  74.     SSelf = function(mapId,eventId,name,bool) {
  75.         var mapId, eventId, name, bool
  76.         $gameSelfSwitches.setValue([mapId,eventId,name], bool);
  77.     }
  78.    
  79.     RSelf = function(mapId,eventId,name) {
  80.         var mapId, eventId, name
  81.         return $gameSelfSwitches.value([mapId,eventId,name])
  82.     }
  83.    
  84.     add_gold = function(value) {
  85.         var value
  86.         $gameParty.gainGold(value);
  87.     }
  88.    
  89.     add_item = function(itemId, n) {
  90.         var itemId,n
  91.         $gameParty.gainItem($dataItems[itemId], n);
  92.     }
  93.    
  94.     add_weapon = function(weaponId,n,bool) {
  95.         var weaponId, n, bool
  96.         $gameParty.gainItem($dataWeapons[weaponId], n, bool);
  97.     }
  98.    
  99.     add_armor = function(armorId,n,bool) {
  100.         var armorId, n, bool
  101.         $gameParty.gainItem($dataArmors[armorId], n, bool);
  102.     }
  103.    
  104.     actor_add = function(actorId) {
  105.         var actorId
  106.         $gameParty.addActor(actorId)
  107.     }
  108.    
  109.     actor_remove = function(actorId) {
  110.         var actorId
  111.         $gameParty.removeActor(actorId)
  112.     }
  113.    
  114.     actor_hp_add = function(actorId,n) {
  115.         var actorId, n
  116.         $gameActors.actor(actorId).gainHp(n)   
  117.     }
  118.    
  119.     actor_mp_add = function(actorId,n) {
  120.         var actorId, n
  121.         $gameActors.actor(actorId).gainMp(n)   
  122.     }
  123.    
  124.     actor_tp_add = function(actorId,n) {
  125.         var actorId, n
  126.         $gameActors.actor(actorId).gainTp(n)   
  127.     }
  128.    
  129.     actor_vadd = function(actorId, nHP, nMP, nTP) {
  130.         var actorId, nHP, nMP, nTP
  131.         $gameActors.actor(actorId).gainHp(nHP)
  132.         $gameActors.actor(actorId).gainMp(nMP)
  133.         $gameActors.actor(actorId).gainTp(nTP)
  134.     }
  135.    
  136.     actor_st_add = function(actorId, n) {
  137.          var actorId, n
  138.          $gameActors.actor(actorId).addState(n);
  139.     }
  140.    
  141.     actor_st_remove = function(actorId, n) {
  142.         var actorId, n
  143.         $gameActors.actor(actorId).removeState(n)
  144.     }
  145.    
  146.     actor_change_exp = function(actorId,n) {
  147.         var actorId, n
  148.         $gameActors.actor(actorId).gainExp(n);
  149.     }
  150.    
  151.     actor_change_lvl = function(actorId, n, bool) {
  152.         var actor_Id, n, bool
  153.         $gameActors.actor(actorId).changeLevel(n, bool);
  154.     }
  155.    
  156.     actor_change_params = function(actorId, paramId, n) {
  157.         var actor_Id, paramId, n
  158.         $gameActors.actor(actorId).addParam(paramId, n);
  159.     }
  160.    
  161.     actor_skill_l = function(actorId, n) {
  162.         var actorId, n
  163.         $gameActors.actor(actorId).learnSkill(n);
  164.     }
  165.    
  166.     actor_skill_f = function(actorId, n) {
  167.         var actorId, n
  168.         $gameActors.actor(actorId).forgetSkill(n);
  169.     }
  170.    
  171.     actor_equip_w = function(actorId,slotId,item) {
  172.         var actorId, slotId, item
  173.         $gameActors.actor(actorId).changeEquip(slotId, $dataWeapons[item]);
  174.     }
  175.    
  176.     actor_equip_a = function(actorId,slotId,item) {
  177.         var actorId, slotId, item
  178.         $gameActors.actor(actorId).changeEquip(slotId, $dataArmors[item]);
  179.     }
  180.    
  181.     actor_change_name = function(actorId,n) {
  182.         var actorId, n
  183.         $gameActors.actor(actorId).setName(n)
  184.     }
  185.    
  186.     actor_change_class = function(actorId,n,bool) {
  187.         var actorId, n, bool
  188.         $gameActors.actor(actorId).changeClass(n, bool)
  189.     }
  190.    
  191.     actor_change_handle = function(actorId, n) {
  192.         var actorId, n
  193.         $gameActors.actor(actorId).setNickname(n)
  194.     }
  195.    
  196.     actor_change_profile = function(actorId, n) {
  197.         var actorId, n
  198.         $gameActors.actor(actorId).setProfile(n)
  199.     }  
  200.    
  201.     transfer = function(mapId, x, y, direction, fadetype) {
  202.         var mapId, x, y, direction, fadetype
  203.         $gamePlayer.reserveTransfer(mapId, x, y, direction, fadetype);
  204.     }
  205.    
  206.     transfer_event = function(eventId,x,y) {
  207.         var eventId, x, y
  208.         $gameMap.event(eventId).setPosition(x, y)
  209.     }
  210.    
  211.     equip_id = function(actorId, n) {
  212.         var actorId, n
  213.         if ($gameActors.actor(actorId).equips()[n]) {
  214.         return $gameActors.actor(actorId).equips()[n].id
  215.         }
  216.     }
  217.    
  218.     equip_name = function(actorId, n) {
  219.         var actorId, n
  220.         if ($gameActors.actor(actorId).equips()[n]) {
  221.         return $gameActors.actor(actorId).equips()[n].name
  222.         }
  223.     }
  224.    
  225.     actor_weaponC = function(actorId, n) {
  226.         var actorId, n
  227.         return $gameActors.actor(actorId).equips().contains($dataWeapons[n])
  228.     }
  229.    
  230.     actor_armorC = function(actorId, n) {
  231.         var actorId, n
  232.         return $gameActors.actor(actorId).equips().contains($dataArmors[n])
  233.     }
  234.    
  235.     actor_skillC = function(actorId, n) {
  236.         var actorId, n
  237.         return $gameActors.actor(actorId).skills().contains($dataSkills[n])
  238.     }
  239.    
  240.     pic_show = function(pictureId, name, origin, x , y ,  scaleX, scaleY, opacity, blendMode) {
  241.         var pictureId, name, origin, scaleX, scaleY, opacity, blendMode, x , y
  242.         $gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode)
  243.     }
  244.    
  245.     pic_move = function(pictureId, origin, x , y,  scaleX, scaleY, opacity, blendMode, duration) {
  246.         var pictureId, origin, scaleX, scaleY, opacity, blendMode, x , y , duration
  247.         $gameScreen.movePicture(pictureId, origin, x, y, scaleX, scaleY, opacity, blendMode, duration)
  248.     }
  249.    
  250.     pic_rotate = function(pictureId, speed) {
  251.         var pictureId, speed
  252.         $gameScreen.rotatePicture(pictureId, speed);
  253.     }
  254.    
  255.     pic_tint = function(pictureId, tone, duration) {
  256.         var pictureId, tone, duration
  257.         $gameScreen.tintPicture(pictureId, tone, duration);
  258.     }
  259.    
  260.     pic_erase = function(pictureId) {
  261.         var pictureId
  262.         $gameScreen.erasePicture(pictureId);
  263.     }
  264.    
  265.     pic_clear = function() {
  266.         $gameScreen.clearPictures()
  267.     }
  268.    
  269.     player_x = function() {
  270.         return $gamePlayer.x
  271.     }
  272.  
  273.     player_y = function() {
  274.         return $gamePlayer.y
  275.     }
  276.    
  277.     event_x = function(eventId) {
  278.         var eventId
  279.         return $gameMap.events()[eventId].x
  280.     }
  281.    
  282.     event_y = function(eventId) {
  283.         var eventId
  284.         return $gameMap.events()[eventId].y
  285.     }
  286.    
  287.     gold = function() {
  288.         return $gameParty.gold()
  289.     }
  290.    
  291.     eval(script);
  292.     return true;
  293. };
  294.  
  295. // Game Variables modifications!
  296. // This will create the SVA and RVA function for script
  297. // to use.
  298.  
  299.  
  300. //Below is my script for modifying the value at index from an array
  301.   var _Game_Variables_Astfgl66 = Game_Variables.prototype.SVA;
  302.   //Modifying a value in an array
  303. Game_Variables.prototype.SVA = function(variableId, index, value) {
  304.     if (variableId > 0 &&variableId < $dataSystem.variables.length) {
  305.         var index
  306.         if (typeof value === 'number') {
  307.             value = Math.floor(value);
  308.         }
  309.         //if (index > this._data[variableId].length-1) {index = this._data[variableId].length-1}
  310.         //remove the comment tags if you don't want this function to create new indexes
  311.         if (index < 0) {index = 0}
  312.         this._data[variableId][index] = value; //Just added [index]
  313.         this.onChange();
  314.     }
  315. };
  316. //End
  317.  
  318. // Below is the script for reading value from an array at index
  319.    var _Game_Variables_Astfgl66 = Game_Variables.prototype.RVA;
  320.  
  321. Game_Variables.prototype.RVA = function(variableId, index) {
  322.    //Reading value at index in an array
  323.     var variableId, index
  324.     return this._data[variableId][index] || 0; //Just added [index]
  325. };
  326.  
  327.  
  328.  
  329.   })();  // dont touch this.
RAW Paste Data