Theo - Limited Inventory (for MV)

● ARCHIVED · READ-ONLY
Started by TheoAllen 35 posts Page 2 of 2 View original ↗
  1. I did some more testing and the only time it doesn't give me a NaN is if I disable the Dynamic Slot parameter. Anyone else having this issue?
  2. After talking with a few other folks on Discord I don't think this dynamic slot feature was ever actually tested...
  3. Hello! This is an awesome plugin! Thank you for sharing it!
    I was wondering if I could get a little advice. I'd like to either hide or move the item slot window in the main menu scene, but I'm unsure where to find it in the script. I'd love it if someone could help me locate it. Thanks a bunch!

    Edit:

    Naturally, I figured it out seconds after posting. If anyone else needs this info, it can be found starting on line 648 and looks like this:
    Code:
    Scene_Menu.prototype.createLinvWindow = function(){
        this._linvWindow = new Theo.LINV.Window_MainMenu(this._goldWindow.width);
        this._linvWindow.x = this._commandWindow.x;
        this._linvWindow.y = this._commandWindow.height;
        this._linvWindow.refresh();
        this.addWindow(this._linvWindow);
    }
  4. I am not sure how many do still use this, but I found a quick fix for NAN in inventory window. As its 0.9 plugin, the calculations in line 243 are incorrect when it comes to States. I deleted it (as of my limited scripting knowledge) and it now works. I added variable number there instead, so you can manage your max depending on items, class and a variable that you setup. Current Variable is 5. You can change it if you want to. Here is the plugin:

    Plugin
    /*: @plugindesc Limits carrying capacity like in many popular games. Version 0.9 [USER=139031]@Author[/USER] TheoAllen [USER=41152]@Help[/USER] This script allow you to limit your inventory by overall possesed items instead of individual items. IMPORTANT NOTE: Name the file of this plugin literally as "TheoLimitedInventory.js" Notetags : write down these notetags to the notebox in your database <inv size: n> Use this notetag where the n is a numeric value which is determine the size of item. Use 0 for unlimited item. Only works for item and equipment such as weapon or armor. <inv plus: n> Use this notetag to determine the additional avalaible free inventory slot. This notetag avalaible for Actor, Class, Equip, and States. If it's for actor, avalaible inventory slot will increase when a new actor entered party. If it's for equip, the avalaible slot will be increase if the certain equip is equipped. And so do states. This value can be changed by script call during the game. Just check the script call instruction. <inv minus: n> Inverse of <inv plus>. It will decrease the avalaible inventory slot. Should be self explanatory TO DO LIST > Make it more touch input friendly > Add inventory slot eval formula > Maybe, some compatibility patch Terms of use : Credit me, TheoAllen. You are free to edit this script by your own. As long as you don't claim it yours. For commercial purpose, don't forget to give me a free copy of the game. @param Preferences @param dynamic @parent Preferences @text Dynamic Slot @type boolean [USER=57405]@Default[/USER] true [USER=168581]@desc[/USER] If set to true, then total avalaible inventory slot depends on actor, states, total party members, etc ... @param displayItem @parent Preferences @text Display Item Size @type boolean [USER=57405]@Default[/USER] true [USER=168581]@desc[/USER] Diplay item size in item menu @param includeEquip @parent Preferences @text Include Equip @type boolean [USER=57405]@Default[/USER] false [USER=168581]@desc[/USER] Total used inventory slot will also include actor equipment. @param drawTotalSize @parent Preferences @text Draw Total Size @type boolean [USER=57405]@Default[/USER] true [USER=168581]@desc[/USER] If true, item size window will show total weight of specified item. 10 potions with 3 weight each = show 30 instead of 3 @param forceGain @parent Preferences @text Force Gain Item @type boolean [USER=57405]@Default[/USER] false [USER=168581]@desc[/USER] Force gain item even if inventory full. (Recommended to set some penalties if inventory is full) @param fullDisableDash @parent Preferences @text Disable Dash at Full @type boolean [USER=57405]@Default[/USER] false [USER=168581]@desc[/USER] When the inventory is at full, disable dashing @param fullSlowDown @parent Preferences @text Slowdowns at full @type boolean [USER=57405]@Default[/USER] false [USER=168581]@desc[/USER] When the inventory is at full, slow down the movement @param Numeric Setting @param defaultFree @parent Numeric Setting @text Default Free Slot @type number [USER=57405]@Default[/USER] 20 [USER=168581]@desc[/USER] Default free slot provided by each actor. If Dynamic slot set to false. It will be use this setting for the free slot @param nearMaxPercent @parent Numeric Setting @text Near Maximum Percentage @type number [USER=57405]@Default[/USER] 25 [USER=168581]@desc[/USER] Remain avalaible slot percentage to determine if the inventory is almost maxed out or not. @param nearMaxColor @parent Numeric Setting @text Near Maximum Color ID @type number [USER=57405]@Default[/USER] 21 [USER=168581]@desc[/USER] Color ID to draw the number @param commandSize @parent Numeric Setting @text Use Command Size @type number [USER=57405]@Default[/USER] 340 [USER=168581]@desc[/USER] The width of use item command window @param Vocab Settings @param invSlotVocab @parent Vocab Settings @text Inventory Slot [USER=57405]@Default[/USER] Inventory: [USER=168581]@desc[/USER] Vocab for inventory @param invSizeVocab @parent Vocab Settings @text Size Vocab [USER=57405]@Default[/USER] Size: [USER=168581]@desc[/USER] Vocab for Size @param slotShort @parent Vocab Settings @text Inventory Slot (Short) [USER=57405]@Default[/USER] Inv: [USER=168581]@desc[/USER] Vocab for inventory (short) @param useVocab @parent Vocab Settings @text Use Vocab [USER=57405]@Default[/USER] Use Item [USER=168581]@desc[/USER] Vocab for using an item @param discardVocab @parent Vocab Settings @text Discard Vocab [USER=57405]@Default[/USER] Discard [USER=168581]@desc[/USER] Vocab for discarding an item @param cancelVocab @parent Vocab Settings @text Cancel Vocab [USER=57405]@Default[/USER] Cancel [USER=168581]@desc[/USER] Vocab for canceling */ var Theo = Theo || function(){ throw new Error('This is a static class')} Theo.LINV = {} Theo.LINV.Params = PluginManager.parameters('TheoLimitedInventory') Theo.LINV.invSizeREGX = /<inv[\s_]+size\s*:\s*(\d+)>/i Theo.LINV.invPlusREGX = /<inv[\s_]+plus\s*:\s*(\d+)>/i Theo.LINV.invMinsREGX = /<inv[\s_]+minus\s*:\s*(\d+)/i //=================================================================== // ** DataManager //=================================================================== Theo.LINV.dbLoaded = DataManager.isDatabaseLoaded; DataManager.isDatabaseLoaded = function(){ if (!Theo.LINV.dbLoaded.call(this)) {return false}; if (!Theo.LINV.invLoaded) { Theo.LINV.loadActorDefault($dataActors); let database = [$dataActors, $dataClasses, $dataWeapons, $dataArmors, $dataStates, $dataItems]; database.forEach(function(data){ data.forEach(function(db){ if(db === null){return}; Theo.LINV.loadData(db); }) }) Theo.LINV.invLoaded = true; } return true; } Theo.LINV.loadActorDefault = function(actors){ actors.forEach(function(actor){ if(!actor){return}; actor.invMod = Number(Theo.LINV.Params['defaultFree']); }) } Theo.LINV.loadData = function(db){ if (!db.invMod){db.invMod = 0}; db.invSize = 1; let notedata = db.note.split(/[\r\n]+/); notedata.forEach(function(line){ if(line.match(Theo.LINV.invSizeREGX)){ db.invSize = Number(RegExp.$1); }else if(line.match(Theo.LINV.invPlusREGX)){ db.invMod = Number(RegExp.$1); }else if(line.match(Theo.LINV.invMinsREGX)){ db.invMod = Number(RegExp.$1) * -1; } }); } //=================================================================== // ** Game_Actor //=================================================================== Theo.LINV.actorSetup = Game_Actor.prototype.setup; Game_Actor.prototype.setup = function(actorId) { Theo.LINV.actorSetup.call(this, actorId); var actor = $dataActors[actorId]; this._baseInv = actor.invMod; }; Game_Actor.prototype.getBaseInv = function(){ return this._baseInv; } Game_Actor.prototype.setBaseInv = function(num){ return this._baseInv = num; } Game_Actor.prototype.equipSize = function(){ if (Theo.LINV.Params['includeEquip'] === 'false'){return 0}; return this.equips().reduce(function(total, eq){ if(eq === null){return total + 0}; return total + eq.invSize; },0); } // IMPORTANT VARIABLE Game_Actor.prototype.invMax = function(){ var size = this.getBaseInv(); size += $dataClasses[this._classId].invMod; size += $gameVariables.value(5) size += this.equips().reduce(function(total, eq){ if(!eq){return total + 0}; return total + eq.invMod; },0); return Number(size); } // Overwrite Game_Actor.prototype.tradeItemWithParty = function(newItem, oldItem) { if (newItem && !$gameParty.hasItem(newItem)) { return false; }else{ $gameParty.forceGainItem(oldItem, 1); $gameParty.forceGainItem(newItem, -1); return true; } }; //=================================================================== // ** Game_Party //=================================================================== Theo.LINV.partyInit = Game_Party.prototype.initialize; Game_Party.prototype.initialize = function(){ this._baseInv = (Theo.LINV.Params['dynamic'] === 'true' ? 0 : Number(Theo.LINV.Params['defaultFree'])) Theo.LINV.partyInit.call(this); } Game_Party.prototype.getBaseInv = function(){ return this._baseInv; } Game_Party.prototype.setBaseInv = function(num){ return this._baseInv = num; } Game_Party.prototype.invMax = function(){ if(Theo.LINV.Params['dynamic'] === 'false'){return this._baseInv}; return this.members().reduce(function(total, member){ return total + member.invMax(); }, 0) + this._baseInv; } Game_Party.prototype.isInvMaxed = function(){ return this.invMax() <= this.totalInvSize(); } Game_Party.prototype.totalInvSize = function(){ var numitem = this.numItems.bind(this); var size = this.allItems().reduce(function(total, item){ if(!item){return total + 0}; return total + item.invSize * numitem(item); },0); size += this.members().reduce(function(total, member){ return total + member.equipSize(); }, 0); return size } // Overwrite Theo.LINV.partyMaxItem = Game_Party.prototype.maxItems; Game_Party.prototype.maxItems = function(item) { if (DataManager.isBattleTest()){ return Theo.LINV.partyMaxItem.call(this, item) }else{ return this.invMaxItem(item) + this.numItems(item); }; }; Game_Party.prototype.invMaxItem = function(item){ if(!item || item === null || item.invSize === 0){return 999999}; return Math.floor(this.freeSlot() / item.invSize); } Game_Party.prototype.freeSlot = function(){ return this.invMax() - this.totalInvSize(); } // Overwrite Theo.LINV.partyHasMaxItem = Game_Party.prototype.hasMaxItems; Game_Party.prototype.hasMaxItems = function(item) { if (DataManager.isBattleTest()){ return Theo.LINV.partyHasMaxItem.call(this, item) }else{ return this.isInvMaxed(); }; }; Game_Party.prototype.isNearingMax = function(){ return this.freeSlot() / this.invMax() <= Number(Theo.LINV.Params['nearMaxPercent'])/100 } Game_Party.prototype.itemSize = function(item){ if(!item){return 0}; return item.invSize * this.numItems(item); } Game_Party.prototype.forceGainItem = function(item, amount, includeEquip){ var container = this.itemContainer(item); if (container) { var lastNumber = this.numItems(item); var newNumber = lastNumber + amount; container[item.id] = Math.max(newNumber, 0); if (container[item.id] === 0) { delete container[item.id]; } if (includeEquip && newNumber < 0) { this.discardMembersEquip(item, -newNumber); } $gameMap.requestRefresh(); } } // Overwrite Game_Party.prototype.loseItem = function(item, amount, includeEquip) { this.forceGainItem(item, -amount, includeEquip); }; // Overwrite Theo.LINV.partyGainItem = Game_Party.prototype.gainItem; Game_Party.prototype.gainItem = function(item, amount, includeEquip) { if(Theo.LINV.Params['forceGain'] === 'true'){ Theo.LINV.partyGainItem.call(this, item, amount, includeEquip); }else{ this.forceGainItem(item, amount, includeEquip); } }; //=================================================================== // ** Game_Player //=================================================================== Theo.LINV.playerIsDashing = Game_Player.prototype.isDashing; Game_Player.prototype.isDashing = function() { if(Theo.LINV.Params['fullDisableDash'] === 'true' && $gameParty.isInvMaxed()){return false}; return Theo.LINV.playerIsDashing.call(this); }; // This need confirmation if it's okay Theo.LINV.playerRealSpeed = Game_CharacterBase.prototype.realMoveSpeed; Game_Player.prototype.realMoveSpeed = function() { return Theo.LINV.playerRealSpeed.call(this) - this.movePenalty(); }; Game_Player.prototype.movePenalty = function(){ return (Theo.LINV.Params['fullSlowDown'] === 'true' && $gameParty.isInvMaxed() ? 1 : 0); } //=================================================================== // ** Window_Base //=================================================================== Window_Base.prototype.drawInvSlot = function(x, y, width, align = 'right'){ let total = String($gameParty.totalInvSize()); let invmax = String($gameParty.invMax()); let txt = total + "/" + invmax; console.log(invmax); let colorId = Number(Theo.LINV.Params['nearMaxColor']); if ($gameParty.isNearingMax()){ this.changeTextColor(this.textColor(colorId)); }else{ this.changeTextColor(this.normalColor()); } this.drawText(txt,x,y,width,align) this.changeTextColor(this.normalColor()) } Window_Base.prototype.drawInvInfo = function(x,y,width){ this.changeTextColor(this.systemColor()); this.drawText(Theo.LINV.Params['invSlotVocab'],x,y,width,0); this.changeTextColor(this.normalColor()); this.drawInvSlot(x, y, width); } Window_Base.prototype.drawItemSize = function(item, x, y, width){ this.changeTextColor(this.systemColor()); this.drawText(Theo.LINV.Params['invSizeVocab'], x, y, width); this.changeTextColor(this.normalColor()); // console.log($gameParty.itemSize(item)); // console.log(item.invSize); let num = (Theo.LINV.Params['drawTotalSize'] === 'true') ? $gameParty.itemSize(item) : (!item ? 0 : item.invSize); // console.log(num); this.drawText(num, x, y, width, 'right'); } //=================================================================== // ** Limited Inventory - Window_MainMenu //=================================================================== Theo.LINV.Window_MainMenu = function(){ this.initialize.apply(this, arguments); } Theo.LINV.Window_MainMenu.prototype = Object.create(Window_Base.prototype); Theo.LINV.Window_MainMenu.prototype.constructor = Theo.LINV.Window_MainMenu; Theo.LINV.Window_MainMenu.prototype.initialize = function(width) { Window_Base.prototype.initialize.call(this,0,0,width,this.fittingHeight(1)); }; Theo.LINV.Window_MainMenu.prototype.refresh = function(){ this.contents.clear(); this.changeTextColor(this.systemColor()); let txt = Theo.LINV.Params['slotShort']; this.drawText(txt, 0, 0, this.contents.width); this.drawInvSlot(0, 0, this.contents.width); } //=================================================================== // ** Limited Inventory - Window_ItemSize //=================================================================== Theo.LINV.Window_ItemSize = function(){ this.initialize.apply(this, arguments); } Theo.LINV.Window_ItemSize.prototype = Object.create(Window_Base.prototype); Theo.LINV.Window_ItemSize.prototype.constructor = Theo.LINV.Window_ItemSize; Theo.LINV.Window_ItemSize.prototype.initialize = function(x,y,width) { Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1)); }; Theo.LINV.Window_ItemSize.prototype.setItem = function(item) { this.item = item; this.refresh(); } Theo.LINV.Window_ItemSize.prototype.refresh = function(){ this.contents.clear(); this.drawItemSize(this.item,0,0,this.contents.width); } //=================================================================== // ** Limited Inventory - Window_FreeSlot //=================================================================== Theo.LINV.Window_FreeSlot = function(){ this.initialize.apply(this, arguments); } Theo.LINV.Window_FreeSlot.prototype = Object.create(Window_Base.prototype); Theo.LINV.Window_FreeSlot.prototype.constructor = Theo.LINV.Window_FreeSlot; Theo.LINV.Window_FreeSlot.prototype.initialize = function(x,y,width) { Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1)); this.refresh(); }; Theo.LINV.Window_FreeSlot.prototype.refresh = function(){ this.contents.clear(); this.drawInvInfo(0,0,this.contents.width); } //=================================================================== // ** Limited Inventory - Window_ItemUse //=================================================================== Theo.LINV.Window_ItemUse = function(){ this.initialize.apply(this, arguments); } Theo.LINV.Window_ItemUse.prototype = Object.create(Window_Command.prototype); Theo.LINV.Window_ItemUse.prototype.constructor = Theo.LINV.Window_ItemUse; Theo.LINV.Window_ItemUse.prototype.initialize = function(){ Window_Command.prototype.initialize.call(this, 0, 0); this._openness = 0; this.deactivate(); } Theo.LINV.Window_ItemUse.prototype.setItem = function(item){ this._item = item; this.refresh(); } Theo.LINV.Window_ItemUse.prototype.windowWidth = function() { return Number(Theo.LINV.Params[`commandSize`]); }; Theo.LINV.Window_ItemUse.prototype.makeCommandList = function(){ this.addCommand(Theo.LINV.Params['useVocab'], 'use', $gameParty.canUse(this._item)); this.addCommand(Theo.LINV.Params['discardVocab'], 'discard', this.discardAble(this._item)); this.addCommand(Theo.LINV.Params['cancelVocab'], 'cancel'); } Theo.LINV.Window_ItemUse.prototype.toCenter = function(){ this.x = Graphics.width/2 - this.width/2; this.y = Graphics.height/2 - this.height/2 - 20; } Theo.LINV.Window_ItemUse.prototype.discardAble = function(item){ if(!item) {return false}; if(item.itypeId) {return item.itypeId !== 2} else{return true}; } //=================================================================== // ** Limited Inventory - Window_Discard //=================================================================== Theo.LINV.Window_Discard = function(){ this.initialize.apply(this, arguments); } Theo.LINV.Window_Discard.prototype = Object.create(Window_Base.prototype); Theo.LINV.Window_Discard.prototype.constructor = Theo.LINV.Window_Discard; Theo.LINV.Window_Discard.prototype.initialize = function(x,y,width){ Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1)); this._openness = 0; this._amount = 0; this.setCursorRect(0, 0, this.contents.width, this.contents.height); this.active = true; } Theo.LINV.Window_Discard.prototype.setItem = function(item){ this._item = item; this._amount = 0; this.refresh(); } Theo.LINV.Window_Discard.prototype.refresh = function(){ this.contents.clear(); if(!this._item){return}; this.drawItemName(this._item, 2, 2, this.contents.width); let txt = String(this._amount)+"/"+String($gameParty.numItems(this._item)); this.drawText(txt,0,1,this.contents.width-2,'right') } Theo.LINV.Window_Discard.prototype.drawItemName = function(item, x, y, width){ if(!item){return}; this.drawIcon(item.iconIndex, x, y); this.drawText(item.name + ":",x + 36, y, width); } Theo.LINV.Window_Discard.prototype.update = function(){ Window_Base.prototype.update.call(this); if (!this.isOpen()){return}; if (Input.isRepeated('right')) {this.changeAmount(1)}; if (Input.isRepeated('left')) {this.changeAmount(-1)}; if (Input.isRepeated('up')) {this.changeAmount(10)}; if (Input.isRepeated('down')) {this.changeAmount(-10)}; if (Input.isTriggered('ok')){this.loseItem()}; if (Input.isTriggered('cancel')){this.closeWindow()}; } Theo.LINV.Window_Discard.prototype.changeAmount = function(amount){ this._amount = (this._amount + amount).clamp(0,$gameParty.numItems(this._item)); SoundManager.playCursor(); this.refresh(); } Theo.LINV.Window_Discard.prototype.loseItem = function(){ $gameParty.loseItem(this._item,this._amount); this.itemList.redrawCurrentItem(); this.freeSlot.refresh(); if($gameParty.numItems(this._item) === 0){ SoundManager.playOk(); this.itemList.activate(); this.itemList.refresh(); this.itemList.updateHelp(); this.commandWindow.close(); this.commandWindow.deactivate(); this.close(); }else{ this.closeWindow(); } } Theo.LINV.Window_Discard.prototype.closeWindow = function(){ this.close(); this.commandWindow.activate(); SoundManager.playOk(); } //=================================================================== // ** Default Script - Window_ItemList //=================================================================== Window_ItemList.prototype.itemSizeWindow = function(w){ this._itemSizeWindow = w; this._itemSizeWindow.setItem(this.item); } Theo.LINV.itemList_updateHelp = Window_ItemList.prototype.updateHelp; Window_ItemList.prototype.updateHelp = function(){ Theo.LINV.itemList_updateHelp.call(this); if (!this._itemSizeWindow){return}; this._itemSizeWindow.setItem(this.item()); } Window_ItemList.prototype.changeHeight = function(height){ this.height = height; this.refresh(); } // Overwrite Window_ItemList.prototype.isEnabled = function(item) { if (item){return true}else{return false}; }; //=================================================================== // ** Default Script - Window_ShopNumber //=================================================================== //=================================================================== // ** Default Script - Window_ShopStatus //=================================================================== //=================================================================== // ** Default Script - Scene_Menu //=================================================================== Theo.LINV.sceneMenuCreate = Scene_Menu.prototype.create; Scene_Menu.prototype.create = function(){ Theo.LINV.sceneMenuCreate.call(this); this.createLinvWindow(); } Scene_Menu.prototype.createLinvWindow = function(){ this._linvWindow = new Theo.LINV.Window_MainMenu(this._goldWindow.width); this._linvWindow.x = 0; this._linvWindow.y = 90; this._linvWindow.refresh(); this.addWindow(this._linvWindow); } //=================================================================== // ** Default Script - Scene_Item //=================================================================== Theo.LINV.sceneItemCreate = Scene_Item.prototype.create; Scene_Item.prototype.create = function(){ Theo.LINV.sceneItemCreate.call(this); this.resizeItemWindow(); this.createUpperLayer(); this.createFreeslotWindow(); this.createItemsizeWindow(); this.createUsecommandWindow(); this.createDiscardAmount(); this.reoderChilds(); } Scene_Item.prototype.resizeItemWindow = function(){ this._itemWindow.height -= this._itemWindow.lineHeight() * 2; } Scene_Item.prototype.reoderChilds = function(){ this._windowLayer.children.findIndex(function(element){ if (element === this._actorWindow){ this._windowLayer.removeChild(element); this._windowLayer.addChild(element); return true; } return false; },this); } Scene_Item.prototype.createUpperLayer = function(){ let width = Graphics.boxWidth; let height = Graphics.boxHeight; let x = (Graphics.width - width) / 2; let y = (Graphics.height - height) / 2; this._useLayer = new WindowLayer(); this._useLayer.move(x, y, width, height); this.addChild(this._useLayer); } Scene_Item.prototype.addUpperWindow = function(w){ this._useLayer.addChild(w); } Scene_Item.prototype.createFreeslotWindow = function(){ let wy = this._itemWindow.y + this._itemWindow.height; let wh = Theo.LINV.Params['displayItem'] === 'true' ? Graphics.width/2 : Graphics.width; this._freeSlot = new Theo.LINV.Window_FreeSlot(0,wy,wh); this.addWindow(this._freeSlot); } Scene_Item.prototype.createItemsizeWindow = function(){ if(Theo.LINV.Params['displayItem'] === 'false'){return}; let wx = this._freeSlot.width let wy = this._freeSlot.y let ww = wx this._itemSize = new Theo.LINV.Window_ItemSize(wx,wy,ww) this._itemWindow._itemSizeWindow = this._itemSize this.addWindow(this._itemSize) } Scene_Item.prototype.createUsecommandWindow = function(){ this._useCommand = new Theo.LINV.Window_ItemUse() this._useCommand.toCenter() this._useCommand.setHandler('use', this.useCommandOk.bind(this)) this._useCommand.setHandler('discard', this.onDiscardOk.bind(this)) this._useCommand.setHandler('cancel', this.onUseCancel.bind(this)) this.addUpperWindow(this._useCommand) } Scene_Item.prototype.createDiscardAmount = function(){ let wx = this._useCommand.x let wy = this._useCommand.y + this._useCommand.height let ww = this._useCommand.width this._discardWindow = new Theo.LINV.Window_Discard(wx,wy,ww) this._discardWindow.commandWindow = this._useCommand this._discardWindow.itemList = this._itemWindow this._discardWindow.freeSlot = this._freeSlot this.addUpperWindow(this._discardWindow) } // Overwrite Theo.LINV.sceneItem_OnItemOk = Scene_Item.prototype.onItemOk; Scene_Item.prototype.onItemOk = function(){ this._useCommand.setItem(this.item()) this._useCommand.open() this._useCommand.activate() this._useCommand.select(0) } Theo.LINV.sceneItem_UseItem = Scene_Item.prototype.useItem; Scene_Item.prototype.useItem = function(){ this._useCommand.close() Theo.LINV.sceneItem_UseItem.call(this) this._freeSlot.refresh(); } Scene_Item.prototype.useCommandOk = function(){ Theo.LINV.sceneItem_OnItemOk.call(this); this._useCommand.close(); } Scene_Item.prototype.onDiscardOk = function(){ this._discardWindow.setItem(this.item()) this._discardWindow.open() } Scene_Item.prototype.onUseCancel = function(){ this._itemWindow.activate() this._useCommand.close() this._useCommand.deactivate() } //=================================================================== // ** Default Script - Scene_Shop //===================================================================
  5. TheoAllen said:
    Limited Inventory
    Version : 0.9
    (Not feature complete yet)
    Introduction :
    This script allows you to limit your inventory by overall possessed items instead of an individual item.

    This is my first attempt of writing MV plugin, and this specific plugin was based on a line-by-line conversion of my RGSS3 script counterpart. As such, I may not aware of how to practically correct writing plugins.

    Features :
    • Limit inventory by overall possessed item
    • Each item may have their own size/weight
    • You may increase or decrease inventory limit using states or equipment
    • Ability to discard an item in item menu
    • A penalty for having overburdened like slower movement / disable dash
    Screenshots :
    Spoiler
    View attachment 104388
    View attachment 104389 View attachment 104390
    View attachment 104391

    Download:
    Grab it here

    How to use:
    Download the plugin, drop it in your plugin folder as "TheoLimitedInventory.js",
    Edit configurations and the note tags as described within the plugin's help.

    Credit:
    Credit me as TheoAllen
    Hello Theo, i was testing the plugin and I really liked it, it is by far the most user-friendly limited inventory plugin that i can find in the RPG Maker MV.
    But despite that, i have a little problem with this plugin
    My main menu is customizable (I used the SRD_SuperToolsEngine to modify it) and as you can see in the print, the limit of items in my inventory overlaps my main menu and I can't move, change the size or remove it using the SRD_SuperToolsEngine
    Is there anyway to remove the inventory limit from the main menu and leave it only on the items tab? 1609967566242.png
  6. Okuro said:
    Is there anyway to remove the inventory limit from the main menu and leave it only on the items tab?
    You can delete the entire code in these lines to remove it.
    Or if you know how to write JS, you can put a custom position for it.
    Screenshot_97.png
  7. I don't want the player to get items if the inventory is full.

    How do I check that the player has the inventory full? which plugin command should I use for that?

    I don't want to use the "force gain" option, please help.
  8. There's a script call to check if the inventory is at max
    $gameParty.isInvMaxed()
  9. isaias20 said:
    I don't want the player to get items if the inventory is full.

    How do I check that the player has the inventory full? which plugin command should I use for that?

    I don't want to use the "force gain" option, please help.
    Did you figure out how to do this? I as well don't want the player to be able to gain items when full.
  10. TheoAllen said:
    Is there a way to restrict the weapons/clothing that can be discarded to avoid deleting something important?
    Basically the characteristics of a key objectCaptura de pantalla (415).png
  11. Is there a way to prevent armor / weapons from being discarded?

    I can set regular items as key items and that prevents those from being discarded, but how do I prevent the player from discarding a weapon or a piece of armor?

    I did some digging around on Google and I came across code this plugin's author wrote to fix this issue in RPG Maker VX, however that version of RPG Maker uses Ruby so it won't work for MV.

    Here's the code they wrote; would anyone know how to translate this over to JS?

    Code:
    class Window_ItemUseCommand
      def discardable?(item)
        return false if item.nil? || !item.note[/<undiscardable>/].nil?
        !(item.is_a?(RPG::Item) && item.itype_id == 2)
      end
    end

    Their instructions also said to:

    put this patch right below limited inventory
    I'm not sure if they meant to create a new plugin with just that code in it to place below the main plugin, or to just ad the code to the bottom of the entire plugin.

    As for using the code, looks like it works similar to how MV works with just adding a notetag to the item:
    Just put <undiscardable> in item notebox it will not be able to discarded

    If anyone would know how to translate this code over to get it working for MV that would be amazing since this plugin is super-useful and works really well other than this one issue with being able to discard all non-key items.
  12. I "solved" the discarding items / weapons / armor issue.

    I have "solved" in quotes because it relies on using Yanfly's Item Core plugin, as well as Yanfly's Item Discard plugin.

    However, the order these plugins are loaded is really important. For all this to work you have to load Theo's Limited Inventory plugin ABOVE Yanfly's Item Core plugin. I've had success loading Theo's Limited Inventory plugin directly below Yanfly's Core Engine plugin too.

    However, if you have access to Yanfly's Item Core plugin AND Yanfly's Item Discard plugin, AANNDD you install Theo's Limited Inventory Plugin above Yanfly's Item Core plugin, everything should work nicely together. You can use Yanfly's notetags on items you don't want discarded and you can easily discard any other items.

    I haven't gotten deeper into the weeds on this and there might still be other issues, but I can at least prevent the player from discarding important non-Key items.

    Hope this helps anyone out if anyone is still using this great little plugin.
  13. I fix some bugs and add small features.
    Hope this helps anyone.


    JavaScript:
    /*:
    @plugindesc Limits carrying capacity like in many popular games.
    Version 0.9
    @author TheoAllen
    @help
    This script allow you to limit your inventory by overall possesed
    items instead of individual items.
    
    IMPORTANT NOTE:
    Name the file of this plugin literally as
    "TheoLimitedInventory.js"
        
    Notetags :
    write down these notetags to the notebox in your database
          
    <inv size: n>
    Use this notetag where the n is a numeric value which is determine
    the size of item. Use 0 for unlimited item. Only works for item
    and equipment such as weapon or armor.
    
    <inv plus: n>
    Use this notetag to determine the additional avalaible free
    inventory slot. This notetag avalaible for Actor, Class, Equip,
    and States. If it's for actor, avalaible inventory slot will
    increase when a new actor entered party. If it's for equip, the
    avalaible slot will be increase if the certain equip is equipped.
    And so do states.
    
    This value can be changed by script call during the game. Just
    check the script call instruction.
    
    <inv minus: n>
    Inverse of <inv plus>. It will decrease the avalaible inventory
    slot. Should be self explanatory
    
    <undiscardable>
    Make an item undiscardable.
    
    TO DO LIST
    > Make it more touch input friendly
    > Add inventory slot eval formula
    > Maybe, some compatibility patch
    
    Terms of use :
    Credit me, TheoAllen. You are free to edit this script by your own.
    As long as you don't claim it yours. For commercial purpose, don't
    forget to give me a free copy of the game.
    
    @param Preferences
        
    @param dynamic
    @parent Preferences
    @text Dynamic Slot
    @type boolean
    @default true
    @desc If set to true, then total avalaible inventory slot depends on actor, states, total party members, etc ...
     
    @param displayItem
    @parent Preferences
    @text Display Item Size
    @type boolean
    @default true
    @desc Diplay item size in item menu
     
    @param includeEquip
    @parent Preferences
    @text Include Equip
    @type boolean
    @default false
    @desc Total used inventory slot will also include actor equipment.
    
    @param drawTotalSize
    @parent Preferences
    @text Draw Total Size
    @type boolean
    @default true
    @desc If true, item size window will show total weight of specified item. 10 potions with 3 weight each = show 30 instead of 3
    
    @param forceGain
    @parent Preferences
    @text Force Gain Item
    @type boolean
    @default false
    @desc Force gain item even if inventory full. (Recommended to set some penalties if inventory is full)
    
    @param fullDisableDash
    @parent Preferences
    @text Disable Dash at Full
    @type boolean
    @default false
    @desc When the inventory is at full, disable dashing
    
    @param fullSlowDown
    @parent Preferences
    @text Slowdowns at full
    @type boolean
    @default false
    @desc When the inventory is at full, slow down the movement
    
    @param canDiscardItem
    @parent Preferences
    @text canDiscardItem?
    @type boolean
    @default true
    @desc If set to false, the item discard feature is disabled.
    
    @param Numeric Setting
    
    @param defaultFree
    @parent Numeric Setting
    @text Default Free Slot
    @type number
    @default 20
    @desc Default free slot provided by each actor. If Dynamic slot set to false. It will be use this setting for the free slot
    
    @param nearMaxPercent
    @parent Numeric Setting
    @text Near Maximum Percentage
    @type number
    @default 25
    @desc Remain avalaible slot percentage to determine if the inventory is almost maxed out or not.
    
    @param nearMaxColor
    @parent Numeric Setting
    @text Near Maximum Color ID
    @type number
    @default 21
    @desc Color ID to draw the number
    
    @param commandSize
    @parent Numeric Setting
    @text Use Command Size
    @type number
    @default 340
    @desc The width of use item command window
    
    @param Vocab Settings
    
    @param invSlotVocab
    @parent Vocab Settings
    @text Inventory Slot
    @default Inventory:
    @desc Vocab for inventory
    
    @param invSizeVocab
    @parent Vocab Settings
    @text Size Vocab
    @default Size:
    @desc Vocab for Size
    
    @param slotShort
    @parent Vocab Settings
    @text Inventory Slot (Short)
    @default Inv:
    @desc Vocab for inventory (short)
    
    @param useVocab
    @parent Vocab Settings
    @text Use Vocab
    @default Use Item
    @desc Vocab for using an item
    
    @param discardVocab
    @parent Vocab Settings
    @text Discard Vocab
    @default Discard
    @desc Vocab for discarding an item
    
    @param cancelVocab
    @parent Vocab Settings
    @text Cancel Vocab
    @default Cancel
    @desc Vocab for canceling
    
     */
    var Theo = Theo || function(){ throw new Error('This is a static class')}
    Theo.LINV = {}
    Theo.LINV.Params = PluginManager.parameters('TheoLimitedInventory')
    
    Theo.LINV.invSizeREGX = /<inv[\s_]+size\s*:\s*(\d+)>/i
    Theo.LINV.invPlusREGX = /<inv[\s_]+plus\s*:\s*(\d+)>/i
    Theo.LINV.invMinsREGX = /<inv[\s_]+minus\s*:\s*(\d+)>/i
    Theo.LINV.undiscardableREGX = /<undiscardable>/i
    
    //===================================================================
    // ** DataManager
    //===================================================================
    Theo.LINV.dbLoaded = DataManager.isDatabaseLoaded;
    DataManager.isDatabaseLoaded = function(){
        if (!Theo.LINV.dbLoaded.call(this)) {return false};
        if (!Theo.LINV.invLoaded) {
            Theo.LINV.loadActorDefault($dataActors);
            let database =  [$dataActors, $dataClasses, $dataWeapons, $dataArmors, $dataStates, $dataItems];
            database.forEach(function(data){
                data.forEach(function(db){
                    if(db === null){return};
                    Theo.LINV.loadData(db);
                })
            })
            Theo.LINV.invLoaded = true;
        }
        return true;
    }
    
    Theo.LINV.loadActorDefault = function(actors){
        actors.forEach(function(actor){
            if(!actor){return};
            actor.invMod = Number(Theo.LINV.Params['defaultFree']);
        })
    }
    
    
    Theo.LINV.loadData = function(db){
        if (!db.invMod){db.invMod = 0};
        db.invSize = 1;
        db.undiscardable = false;
        let notedata = db.note.split(/[\r\n]+/);
        notedata.forEach(function(line){
            if(line.match(Theo.LINV.invSizeREGX)){
                db.invSize = Number(RegExp.$1);
            }else if(line.match(Theo.LINV.invPlusREGX)){
                db.invMod = Number(RegExp.$1);
            }else if(line.match(Theo.LINV.invMinsREGX)){
                db.invMod = Number(RegExp.$1) * -1;
            }else if(line.match(Theo.LINV.undiscardableREGX)){
                db.undiscardable = true;
            }
        });
    }
    
    //===================================================================
    // ** Game_Actor
    //===================================================================
    Theo.LINV.actorSetup = Game_Actor.prototype.setup;
    Game_Actor.prototype.setup = function(actorId) {
        Theo.LINV.actorSetup.call(this, actorId);
            var actor = $dataActors[actorId];
        this._baseInv = actor.invMod;
    };
    
    Game_Actor.prototype.getBaseInv = function(){
        if (!this._baseInv) return 0;
        return this._baseInv;
    }
    
    Game_Actor.prototype.setBaseInv = function(num){
        return this._baseInv = num;
    }
    
    Game_Actor.prototype.equipSize = function(){
        if (Theo.LINV.Params['includeEquip'] === 'false'){return 0};
        return this.equips().reduce(function(total, eq){
            if(eq === null){return total + 0};
            return total + eq.invSize;
        },0);
    }
    
    // TO DO = Add Eval
    Game_Actor.prototype.invMax = function(){
        var size = this.getBaseInv();
        size += $dataClasses[this._classId].invMod;
        //size += this.states().reduce(function(total, state){total + state.invMod}, 0);
        size += this.states().reduce(function(total, state){return total + state.invMod}, 0);
        size += this.equips().reduce(function(total, eq){
            if(!eq){return total + 0};
            return total + eq.invMod;
        },0);
        return Number(size);
    }
    
    // Overwrite
    Game_Actor.prototype.tradeItemWithParty = function(newItem, oldItem) {
          if (newItem && !$gameParty.hasItem(newItem)) {
                 return false;
          }else{
                 $gameParty.forceGainItem(oldItem, 1);
                 $gameParty.forceGainItem(newItem, -1);
                 return true;
          }
    };
    //===================================================================
    // ** Game_Party
    //===================================================================
    Theo.LINV.partyInit = Game_Party.prototype.initialize;
    Game_Party.prototype.initialize = function(){
        this._baseInv = (Theo.LINV.Params['dynamic'] === 'true' ? 0 : Number(Theo.LINV.Params['defaultFree']))
        Theo.LINV.partyInit.call(this);
    }
    
    Game_Party.prototype.getBaseInv = function(){
        return this._baseInv;
    }
    
    Game_Party.prototype.setBaseInv = function(num){
        return this._baseInv = num;
    }
    
    Game_Party.prototype.invMax = function(){
        if(Theo.LINV.Params['dynamic'] === 'false'){return this._baseInv};
        return this.members().reduce(function(total, member){
            return total + member.invMax();
        }, 0) + this._baseInv;
    }
    
    Game_Party.prototype.isInvMaxed = function(){
        return this.invMax() <= this.totalInvSize();
    }
    
    Game_Party.prototype.totalInvSize = function(){
        var numitem = this.numItems.bind(this);
        var size = this.allItems().reduce(function(total, item){
        if(!item){return total + 0};
            return total + item.invSize * numitem(item);
        },0);
        size += this.members().reduce(function(total, member){
            return total + member.equipSize();
        }, 0);
        return size
    }
    
    // Overwrite
    Theo.LINV.partyMaxItem = Game_Party.prototype.maxItems;
    Game_Party.prototype.maxItems = function(item) {
          if (DataManager.isBattleTest()){
            return Theo.LINV.partyMaxItem.call(this, item)
        }else{
            return this.invMaxItem(item) + this.numItems(item);
        };
    };
    
    Game_Party.prototype.invMaxItem = function(item){
        if(!item || item === null || item.invSize === 0){return 999999};
        return Math.floor(this.freeSlot() / item.invSize);
    }
    
    Game_Party.prototype.freeSlot = function(){
        return this.invMax() - this.totalInvSize();
    }
    
    // Overwrite
    Theo.LINV.partyHasMaxItem = Game_Party.prototype.hasMaxItems;
    Game_Party.prototype.hasMaxItems = function(item) {
          if (DataManager.isBattleTest()){
            return Theo.LINV.partyHasMaxItem.call(this, item)
        }else{
            return this.isInvMaxed();
        };
    };
    
    Game_Party.prototype.isNearingMax = function(){
        return this.freeSlot() / this.invMax() <= Number(Theo.LINV.Params['nearMaxPercent'])/100
    }
    
    Game_Party.prototype.itemSize = function(item){
        if(!item){return 0};
        return item.invSize * this.numItems(item);
    }
    
    Game_Party.prototype.forceGainItem = function(item, amount, includeEquip){
        var container = this.itemContainer(item);
          if (container) {
            var lastNumber = this.numItems(item);
            var newNumber = lastNumber + amount;
            container[item.id] = Math.max(newNumber, 0);
            if (container[item.id] === 0) {
            delete container[item.id];
            }
            if (includeEquip && newNumber < 0) {
                  this.discardMembersEquip(item, -newNumber);
            }
            $gameMap.requestRefresh();
      }
    }
    
    // Overwrite
    Game_Party.prototype.loseItem = function(item, amount, includeEquip) {
        this.forceGainItem(item, -amount, includeEquip);
    };
    
    // Overwrite
    Theo.LINV.partyGainItem = Game_Party.prototype.gainItem;
    Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
        if(Theo.LINV.Params['forceGain'] === 'true'){
            Theo.LINV.partyGainItem.call(this, item, amount, includeEquip);
        }else{
            this.forceGainItem(item, amount, includeEquip);
        }
    };
    
    //===================================================================
    // ** Game_Player
    //===================================================================
    Theo.LINV.playerIsDashing = Game_Player.prototype.isDashing;
    Game_Player.prototype.isDashing = function() {
        if(Theo.LINV.Params['fullDisableDash'] === 'true' && $gameParty.isInvMaxed()){return false};
      return Theo.LINV.playerIsDashing.call(this);
    };
    
    // This need confirmation if it's okay
    Theo.LINV.playerRealSpeed = Game_CharacterBase.prototype.realMoveSpeed;
    Game_Player.prototype.realMoveSpeed = function() {
      return Theo.LINV.playerRealSpeed.call(this) - this.movePenalty();
    };
    
    Game_Player.prototype.movePenalty = function(){
        return (Theo.LINV.Params['fullSlowDown'] === 'true' && $gameParty.isInvMaxed() ? 1 : 0);
    }
    //===================================================================
    // ** Window_Base
    //===================================================================
    Window_Base.prototype.drawInvSlot = function(x, y, width, align = 'right'){
        let total = String($gameParty.totalInvSize());
        let invmax = String($gameParty.invMax());
        let txt = total + "/" + invmax;
        console.log(invmax);
        let colorId = Number(Theo.LINV.Params['nearMaxColor']);
        if ($gameParty.isNearingMax()){
            this.changeTextColor(this.textColor(colorId));
        }else{
            this.changeTextColor(this.normalColor());
        }
        this.drawText(txt,x,y,width,align)
      this.changeTextColor(this.normalColor())
    }
    
    Window_Base.prototype.drawInvInfo = function(x,y,width){
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSlotVocab'],x,y,width,0);
        this.changeTextColor(this.normalColor());
        this.drawInvSlot(x, y, width);
    }
    
    Window_Base.prototype.drawItemSize = function(item, x, y, width){
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSizeVocab'], x, y, width);
        this.changeTextColor(this.normalColor());
        // console.log($gameParty.itemSize(item));
        // console.log(item.invSize);
        let num = (Theo.LINV.Params['drawTotalSize'] === 'true') ? $gameParty.itemSize(item) : (!item ? 0 : item.invSize);
        // console.log(num);
        this.drawText(num, x, y, width, 'right');
    }
    //===================================================================
    // ** Limited Inventory - Window_MainMenu
    //===================================================================
    Theo.LINV.Window_MainMenu = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_MainMenu.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_MainMenu.prototype.constructor = Theo.LINV.Window_MainMenu;
    
    Theo.LINV.Window_MainMenu.prototype.initialize = function(width) {
      Window_Base.prototype.initialize.call(this,0,0,width,this.fittingHeight(1));
    };
    
    Theo.LINV.Window_MainMenu.prototype.refresh = function(){
        this.contents.clear();
        this.changeTextColor(this.systemColor());
        let txt = Theo.LINV.Params['slotShort'];
        this.drawText(txt, 0, 0, this.contents.width);
        this.drawInvSlot(0, 0, this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_ItemSize
    //===================================================================
    Theo.LINV.Window_ItemSize = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_ItemSize.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_ItemSize.prototype.constructor = Theo.LINV.Window_ItemSize;
    
    Theo.LINV.Window_ItemSize.prototype.initialize = function(x,y,width) {
      Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
    };
    
    Theo.LINV.Window_ItemSize.prototype.setItem = function(item) {
        this.item = item;
        this.refresh();
    }
    
    Theo.LINV.Window_ItemSize.prototype.refresh = function(){
        this.contents.clear();
        this.drawItemSize(this.item,0,0,this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_FreeSlot
    //===================================================================
    Theo.LINV.Window_FreeSlot = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_FreeSlot.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_FreeSlot.prototype.constructor = Theo.LINV.Window_FreeSlot;
    
    Theo.LINV.Window_FreeSlot.prototype.initialize = function(x,y,width) {
      Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
        this.refresh();
    };
    
    Theo.LINV.Window_FreeSlot.prototype.refresh = function(){
        this.contents.clear();
        this.drawInvInfo(0,0,this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_ItemUse
    //===================================================================
    Theo.LINV.Window_ItemUse = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_ItemUse.prototype = Object.create(Window_Command.prototype);
    Theo.LINV.Window_ItemUse.prototype.constructor = Theo.LINV.Window_ItemUse;
    
    Theo.LINV.Window_ItemUse.prototype.initialize = function(){
        Window_Command.prototype.initialize.call(this, 0, 0);
        this._openness = 0;
        this.deactivate();
    }
    
    Theo.LINV.Window_ItemUse.prototype.setItem = function(item){
        this._item = item;
        this.refresh();
    }
    
    Theo.LINV.Window_ItemUse.prototype.windowWidth = function() {
        return Number(Theo.LINV.Params[`commandSize`]);
    };
    
    Theo.LINV.Window_ItemUse.prototype.makeCommandList = function(){
        this.addCommand(Theo.LINV.Params['useVocab'], 'use', $gameParty.canUse(this._item));
        this.addCommand(Theo.LINV.Params['discardVocab'], 'discard', this.discardAble(this._item));
        this.addCommand(Theo.LINV.Params['cancelVocab'], 'cancel');
    }
    
    Theo.LINV.Window_ItemUse.prototype.toCenter = function(){
        this.x = Graphics.width/2 - this.width/2;
        this.y = Graphics.height/2 - this.height/2 - 20;
    }
    
    Theo.LINV.Window_ItemUse.prototype.discardAble = function(item){
        if(!item) {return false};
        if(Theo.LINV.Params['canDiscardItem'] === 'false') {return false}
        if(item.undiscardable) {return false;}
        if(item.itypeId) {return item.itypeId !== 2}
        else{return true};
    }
    //===================================================================
    // ** Limited Inventory - Window_Discard
    //===================================================================
    Theo.LINV.Window_Discard = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_Discard.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_Discard.prototype.constructor = Theo.LINV.Window_Discard;
    
    Theo.LINV.Window_Discard.prototype.initialize = function(x,y,width){
        Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
        this._openness = 0;
        this._amount = 0;
        this.setCursorRect(0, 0, this.contents.width, this.contents.height);
        this.active = true;
    }
    
    Theo.LINV.Window_Discard.prototype.setItem = function(item){
        this._item = item;
        this._amount = 0;
        this.refresh();
    }
    
    Theo.LINV.Window_Discard.prototype.refresh = function(){
        this.contents.clear();
        if(!this._item){return};
        this.drawItemName(this._item, 2, 2, this.contents.width);
        let txt = String(this._amount)+"/"+String($gameParty.numItems(this._item));
        this.drawText(txt,0,1,this.contents.width-2,'right')
    }
    
    Theo.LINV.Window_Discard.prototype.drawItemName = function(item, x, y, width){
        if(!item){return};
        this.drawIcon(item.iconIndex, x, y);
        this.drawText(item.name + ":",x + 36, y, width);
    }
    
    Theo.LINV.Window_Discard.prototype.update = function(){
        Window_Base.prototype.update.call(this);
        if (!this.isOpen()){return};
        if (Input.isRepeated('right')) {this.changeAmount(1)};
        if (Input.isRepeated('left')) {this.changeAmount(-1)};
        if (Input.isRepeated('up')) {this.changeAmount(10)};
        if (Input.isRepeated('down')) {this.changeAmount(-10)};
        if (Input.isTriggered('ok')){this.loseItem()};
        if (Input.isTriggered('cancel')){this.closeWindow()};
    }
    
    Theo.LINV.Window_Discard.prototype.changeAmount = function(amount){
        this._amount = (this._amount + amount).clamp(0,$gameParty.numItems(this._item));
        SoundManager.playCursor();
        this.refresh();
    }
    
    Theo.LINV.Window_Discard.prototype.loseItem = function(){
        $gameParty.loseItem(this._item,this._amount);
        this.itemList.redrawCurrentItem();
        this.freeSlot.refresh();
        if($gameParty.numItems(this._item) === 0){
            SoundManager.playOk();
            this.itemList.activate();
            this.itemList.refresh();
            this.itemList.updateHelp();
            this.commandWindow.close();
            this.commandWindow.deactivate();
            this.close();
        }else{
            this.closeWindow();
        }
    }
    
    Theo.LINV.Window_Discard.prototype.closeWindow = function(){
        this.close();
        this.commandWindow.activate();
        SoundManager.playOk();
    }
    //===================================================================
    // ** Default Script - Window_ItemList
    //===================================================================
    Window_ItemList.prototype.itemSizeWindow = function(w){
        this._itemSizeWindow = w;
        this._itemSizeWindow.setItem(this.item);
    }
    
    Theo.LINV.itemList_updateHelp = Window_ItemList.prototype.updateHelp;
    Window_ItemList.prototype.updateHelp = function(){
        Theo.LINV.itemList_updateHelp.call(this);
        if (!this._itemSizeWindow){return};
        this._itemSizeWindow.setItem(this.item());
    }
    
    Window_ItemList.prototype.changeHeight = function(height){
        this.height = height;
        this.refresh();
    }
    
    // Overwrite
    Window_ItemList.prototype.isEnabled = function(item) {
          if (item){return true}else{return false};
    };
    //===================================================================
    // ** Default Script - Window_ShopNumber
    //===================================================================
    Theo.LINV.shopNumInit = Window_ShopNumber.prototype.initialize;
    Window_ShopNumber.prototype.initialize = function(x,y,height){
        //Window_ShopNumber.prototype.initialize.call(this, x, y, height);
        Theo.LINV.shopNumInit.call(this, x, y, height);
        this._number = 0;
        this._mode = 'buy';
    }
    
    Theo.LINV.shopNumRefresh = Window_ShopNumber.prototype.refresh;
    Window_ShopNumber.prototype.refresh = function(){
        Theo.LINV.shopNumRefresh.call(this);
        this.drawItemSize();
    }
    
    Window_ShopNumber.prototype.lineHeight = function() {
        return Window_Base.prototype.lineHeight.call(this)
    };
    
    Window_ShopNumber.prototype.drawItemSize = function(){
        let num = this._number * $dataItems[this._item.id].invSize;
        let total = $gameParty.totalInvSize() + (this._mode === 'buy' ? num : num * -1);
        let txt = String(total)+"/"+String($gameParty.invMax());
        let ypos = this.itemY() + this.lineHeight() * 4;
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSlotVocab'],6,ypos,this.contents.width-12);
        this.changeTextColor(this.normalColor());
        this.drawText(txt,6,ypos,this.contents.width-12,'right');
    }
    
    //===================================================================
    // ** Default Script - Window_ShopStatus
    //===================================================================
    if (Theo.LINV.Params['displayItem'] === 'true'){
        Theo.LINV.shopStatusPossession = Window_ShopStatus.prototype.drawPossession;
        Window_ShopStatus.prototype.drawPossession = function(x, y){
            Theo.LINV.shopStatusPossession.call(this, x, y);
            y += this.lineHeight();
            this.drawItemSize(this._item, x, y, this.contents.width - (x*2));
        }
    }
    //===================================================================
    // ** Default Script - Scene_Menu
    //===================================================================
    Theo.LINV.sceneMenuCreate = Scene_Menu.prototype.create;
    Scene_Menu.prototype.create = function(){
        Theo.LINV.sceneMenuCreate.call(this);
        this.createLinvWindow();
    }
    
    Scene_Menu.prototype.createLinvWindow = function(){
        this._linvWindow = new Theo.LINV.Window_MainMenu(this._goldWindow.width);
        this._linvWindow.x = this._commandWindow.x;
        this._linvWindow.y = this._commandWindow.height;
        this._linvWindow.refresh();
        this.addWindow(this._linvWindow);
    }
    //===================================================================
    // ** Default Script - Scene_Item
    //===================================================================
    Theo.LINV.sceneItemCreate = Scene_Item.prototype.create;
    Scene_Item.prototype.create = function(){
        Theo.LINV.sceneItemCreate.call(this);
        this.resizeItemWindow();
        this.createUpperLayer();
        this.createFreeslotWindow();
        this.createItemsizeWindow();
        this.createUsecommandWindow();
        this.createDiscardAmount();
        this.reoderChilds();
    }
    
    Scene_Item.prototype.resizeItemWindow = function(){
        this._itemWindow.height -= this._itemWindow.lineHeight() * 2;
    }
    
    Scene_Item.prototype.reoderChilds = function(){
        this._windowLayer.children.findIndex(function(element){
            if (element === this._actorWindow){
                this._windowLayer.removeChild(element);
                this._windowLayer.addChild(element);
                return true;
            }
            return false;
        },this);
    }
    
    Scene_Item.prototype.createUpperLayer = function(){
        let width = Graphics.boxWidth;
        let height = Graphics.boxHeight;
        let x = (Graphics.width - width) / 2;
        let y = (Graphics.height - height) / 2;
        this._useLayer = new WindowLayer();
        this._useLayer.move(x, y, width, height);
        this.addChild(this._useLayer);
    }
    
    Scene_Item.prototype.addUpperWindow = function(w){
        this._useLayer.addChild(w);
    }
    
    Scene_Item.prototype.createFreeslotWindow = function(){
        let wy = this._itemWindow.y + this._itemWindow.height;
        let wh = Theo.LINV.Params['displayItem'] === 'true' ? Graphics.width/2 : Graphics.width;
        this._freeSlot = new Theo.LINV.Window_FreeSlot(0,wy,wh);
        this.addWindow(this._freeSlot);
    }
    
    Scene_Item.prototype.createItemsizeWindow = function(){
        if(Theo.LINV.Params['displayItem'] === 'false'){return};
        let wx = this._freeSlot.width
        let wy = this._freeSlot.y
        let ww = wx
        this._itemSize = new Theo.LINV.Window_ItemSize(wx,wy,ww)
        this._itemWindow._itemSizeWindow = this._itemSize
        this.addWindow(this._itemSize)
    }
    
    Scene_Item.prototype.createUsecommandWindow = function(){
        this._useCommand = new Theo.LINV.Window_ItemUse()
        this._useCommand.toCenter()
        this._useCommand.setHandler('use', this.useCommandOk.bind(this))
        this._useCommand.setHandler('discard', this.onDiscardOk.bind(this))
        this._useCommand.setHandler('cancel', this.onUseCancel.bind(this))
        this.addUpperWindow(this._useCommand)
    }
    
    Scene_Item.prototype.createDiscardAmount = function(){
        let wx = this._useCommand.x
        let wy = this._useCommand.y + this._useCommand.height
        let ww = this._useCommand.width
        this._discardWindow = new Theo.LINV.Window_Discard(wx,wy,ww)
        this._discardWindow.commandWindow = this._useCommand
        this._discardWindow.itemList = this._itemWindow
        this._discardWindow.freeSlot = this._freeSlot
        this.addUpperWindow(this._discardWindow)
    }
    
    // Overwrite
    Theo.LINV.sceneItem_OnItemOk = Scene_Item.prototype.onItemOk;
    Scene_Item.prototype.onItemOk = function(){
        this._useCommand.setItem(this.item())
        this._useCommand.open()
        this._useCommand.activate()
        this._useCommand.select(0)
    }
    
    Theo.LINV.sceneItem_UseItem = Scene_Item.prototype.useItem;
    Scene_Item.prototype.useItem = function(){
        this._useCommand.close()
        Theo.LINV.sceneItem_UseItem.call(this)
        this._freeSlot.refresh();
    }
    
    Scene_Item.prototype.useCommandOk = function(){
        Theo.LINV.sceneItem_OnItemOk.call(this);
        this._useCommand.close();
    }
    
    Scene_Item.prototype.onDiscardOk = function(){
        this._discardWindow.setItem(this.item())
        this._discardWindow.open()
    }
    
    Scene_Item.prototype.onUseCancel = function(){
        this._itemWindow.activate()
        this._useCommand.close()
        this._useCommand.deactivate()
    }
    
    //===================================================================
    //** Default Script - Scene_Shop
    //===================================================================
    Theo.LINV.shopBuyOk = Scene_Shop.prototype.onBuyOk;
    Scene_Shop.prototype.onBuyOk = function() {
        this._numberWindow._mode = 'buy';
        Theo.LINV.shopBuyOk.call(this);
    };
    
    Theo.LINV.shopSellOk = Scene_Shop.prototype.onSellOk;
    Scene_Shop.prototype.onSellOk = function() {
        this._numberWindow._mode = 'sell';
        Theo.LINV.shopSellOk.call(this);
    };
  14. ywh96 said:
    I fix some bugs and add small features.
    Hope this helps anyone.


    JavaScript:
    /*:
    @plugindesc Limits carrying capacity like in many popular games.
    Version 0.9
    @author TheoAllen
    @help
    This script allow you to limit your inventory by overall possesed
    items instead of individual items.
    
    IMPORTANT NOTE:
    Name the file of this plugin literally as
    "TheoLimitedInventory.js"
       
    Notetags :
    write down these notetags to the notebox in your database
         
    <inv size: n>
    Use this notetag where the n is a numeric value which is determine
    the size of item. Use 0 for unlimited item. Only works for item
    and equipment such as weapon or armor.
    
    <inv plus: n>
    Use this notetag to determine the additional avalaible free
    inventory slot. This notetag avalaible for Actor, Class, Equip,
    and States. If it's for actor, avalaible inventory slot will
    increase when a new actor entered party. If it's for equip, the
    avalaible slot will be increase if the certain equip is equipped.
    And so do states.
    
    This value can be changed by script call during the game. Just
    check the script call instruction.
    
    <inv minus: n>
    Inverse of <inv plus>. It will decrease the avalaible inventory
    slot. Should be self explanatory
    
    <undiscardable>
    Make an item undiscardable.
    
    TO DO LIST
    > Make it more touch input friendly
    > Add inventory slot eval formula
    > Maybe, some compatibility patch
    
    Terms of use :
    Credit me, TheoAllen. You are free to edit this script by your own.
    As long as you don't claim it yours. For commercial purpose, don't
    forget to give me a free copy of the game.
    
    @param Preferences
       
    @param dynamic
    @parent Preferences
    @text Dynamic Slot
    @type boolean
    @default true
    @desc If set to true, then total avalaible inventory slot depends on actor, states, total party members, etc ...
     
    @param displayItem
    @parent Preferences
    @text Display Item Size
    @type boolean
    @default true
    @desc Diplay item size in item menu
     
    @param includeEquip
    @parent Preferences
    @text Include Equip
    @type boolean
    @default false
    @desc Total used inventory slot will also include actor equipment.
    
    @param drawTotalSize
    @parent Preferences
    @text Draw Total Size
    @type boolean
    @default true
    @desc If true, item size window will show total weight of specified item. 10 potions with 3 weight each = show 30 instead of 3
    
    @param forceGain
    @parent Preferences
    @text Force Gain Item
    @type boolean
    @default false
    @desc Force gain item even if inventory full. (Recommended to set some penalties if inventory is full)
    
    @param fullDisableDash
    @parent Preferences
    @text Disable Dash at Full
    @type boolean
    @default false
    @desc When the inventory is at full, disable dashing
    
    @param fullSlowDown
    @parent Preferences
    @text Slowdowns at full
    @type boolean
    @default false
    @desc When the inventory is at full, slow down the movement
    
    @param canDiscardItem
    @parent Preferences
    @text canDiscardItem?
    @type boolean
    @default true
    @desc If set to false, the item discard feature is disabled.
    
    @param Numeric Setting
    
    @param defaultFree
    @parent Numeric Setting
    @text Default Free Slot
    @type number
    @default 20
    @desc Default free slot provided by each actor. If Dynamic slot set to false. It will be use this setting for the free slot
    
    @param nearMaxPercent
    @parent Numeric Setting
    @text Near Maximum Percentage
    @type number
    @default 25
    @desc Remain avalaible slot percentage to determine if the inventory is almost maxed out or not.
    
    @param nearMaxColor
    @parent Numeric Setting
    @text Near Maximum Color ID
    @type number
    @default 21
    @desc Color ID to draw the number
    
    @param commandSize
    @parent Numeric Setting
    @text Use Command Size
    @type number
    @default 340
    @desc The width of use item command window
    
    @param Vocab Settings
    
    @param invSlotVocab
    @parent Vocab Settings
    @text Inventory Slot
    @default Inventory:
    @desc Vocab for inventory
    
    @param invSizeVocab
    @parent Vocab Settings
    @text Size Vocab
    @default Size:
    @desc Vocab for Size
    
    @param slotShort
    @parent Vocab Settings
    @text Inventory Slot (Short)
    @default Inv:
    @desc Vocab for inventory (short)
    
    @param useVocab
    @parent Vocab Settings
    @text Use Vocab
    @default Use Item
    @desc Vocab for using an item
    
    @param discardVocab
    @parent Vocab Settings
    @text Discard Vocab
    @default Discard
    @desc Vocab for discarding an item
    
    @param cancelVocab
    @parent Vocab Settings
    @text Cancel Vocab
    @default Cancel
    @desc Vocab for canceling
    
     */
    var Theo = Theo || function(){ throw new Error('This is a static class')}
    Theo.LINV = {}
    Theo.LINV.Params = PluginManager.parameters('TheoLimitedInventory')
    
    Theo.LINV.invSizeREGX = /<inv[\s_]+size\s*:\s*(\d+)>/i
    Theo.LINV.invPlusREGX = /<inv[\s_]+plus\s*:\s*(\d+)>/i
    Theo.LINV.invMinsREGX = /<inv[\s_]+minus\s*:\s*(\d+)>/i
    Theo.LINV.undiscardableREGX = /<undiscardable>/i
    
    //===================================================================
    // ** DataManager
    //===================================================================
    Theo.LINV.dbLoaded = DataManager.isDatabaseLoaded;
    DataManager.isDatabaseLoaded = function(){
        if (!Theo.LINV.dbLoaded.call(this)) {return false};
        if (!Theo.LINV.invLoaded) {
            Theo.LINV.loadActorDefault($dataActors);
            let database =  [$dataActors, $dataClasses, $dataWeapons, $dataArmors, $dataStates, $dataItems];
            database.forEach(function(data){
                data.forEach(function(db){
                    if(db === null){return};
                    Theo.LINV.loadData(db);
                })
            })
            Theo.LINV.invLoaded = true;
        }
        return true;
    }
    
    Theo.LINV.loadActorDefault = function(actors){
        actors.forEach(function(actor){
            if(!actor){return};
            actor.invMod = Number(Theo.LINV.Params['defaultFree']);
        })
    }
    
    
    Theo.LINV.loadData = function(db){
        if (!db.invMod){db.invMod = 0};
        db.invSize = 1;
        db.undiscardable = false;
        let notedata = db.note.split(/[\r\n]+/);
        notedata.forEach(function(line){
            if(line.match(Theo.LINV.invSizeREGX)){
                db.invSize = Number(RegExp.$1);
            }else if(line.match(Theo.LINV.invPlusREGX)){
                db.invMod = Number(RegExp.$1);
            }else if(line.match(Theo.LINV.invMinsREGX)){
                db.invMod = Number(RegExp.$1) * -1;
            }else if(line.match(Theo.LINV.undiscardableREGX)){
                db.undiscardable = true;
            }
        });
    }
    
    //===================================================================
    // ** Game_Actor
    //===================================================================
    Theo.LINV.actorSetup = Game_Actor.prototype.setup;
    Game_Actor.prototype.setup = function(actorId) {
        Theo.LINV.actorSetup.call(this, actorId);
            var actor = $dataActors[actorId];
        this._baseInv = actor.invMod;
    };
    
    Game_Actor.prototype.getBaseInv = function(){
        if (!this._baseInv) return 0;
        return this._baseInv;
    }
    
    Game_Actor.prototype.setBaseInv = function(num){
        return this._baseInv = num;
    }
    
    Game_Actor.prototype.equipSize = function(){
        if (Theo.LINV.Params['includeEquip'] === 'false'){return 0};
        return this.equips().reduce(function(total, eq){
            if(eq === null){return total + 0};
            return total + eq.invSize;
        },0);
    }
    
    // TO DO = Add Eval
    Game_Actor.prototype.invMax = function(){
        var size = this.getBaseInv();
        size += $dataClasses[this._classId].invMod;
        //size += this.states().reduce(function(total, state){total + state.invMod}, 0);
        size += this.states().reduce(function(total, state){return total + state.invMod}, 0);
        size += this.equips().reduce(function(total, eq){
            if(!eq){return total + 0};
            return total + eq.invMod;
        },0);
        return Number(size);
    }
    
    // Overwrite
    Game_Actor.prototype.tradeItemWithParty = function(newItem, oldItem) {
          if (newItem && !$gameParty.hasItem(newItem)) {
                 return false;
          }else{
                 $gameParty.forceGainItem(oldItem, 1);
                 $gameParty.forceGainItem(newItem, -1);
                 return true;
          }
    };
    //===================================================================
    // ** Game_Party
    //===================================================================
    Theo.LINV.partyInit = Game_Party.prototype.initialize;
    Game_Party.prototype.initialize = function(){
        this._baseInv = (Theo.LINV.Params['dynamic'] === 'true' ? 0 : Number(Theo.LINV.Params['defaultFree']))
        Theo.LINV.partyInit.call(this);
    }
    
    Game_Party.prototype.getBaseInv = function(){
        return this._baseInv;
    }
    
    Game_Party.prototype.setBaseInv = function(num){
        return this._baseInv = num;
    }
    
    Game_Party.prototype.invMax = function(){
        if(Theo.LINV.Params['dynamic'] === 'false'){return this._baseInv};
        return this.members().reduce(function(total, member){
            return total + member.invMax();
        }, 0) + this._baseInv;
    }
    
    Game_Party.prototype.isInvMaxed = function(){
        return this.invMax() <= this.totalInvSize();
    }
    
    Game_Party.prototype.totalInvSize = function(){
        var numitem = this.numItems.bind(this);
        var size = this.allItems().reduce(function(total, item){
        if(!item){return total + 0};
            return total + item.invSize * numitem(item);
        },0);
        size += this.members().reduce(function(total, member){
            return total + member.equipSize();
        }, 0);
        return size
    }
    
    // Overwrite
    Theo.LINV.partyMaxItem = Game_Party.prototype.maxItems;
    Game_Party.prototype.maxItems = function(item) {
          if (DataManager.isBattleTest()){
            return Theo.LINV.partyMaxItem.call(this, item)
        }else{
            return this.invMaxItem(item) + this.numItems(item);
        };
    };
    
    Game_Party.prototype.invMaxItem = function(item){
        if(!item || item === null || item.invSize === 0){return 999999};
        return Math.floor(this.freeSlot() / item.invSize);
    }
    
    Game_Party.prototype.freeSlot = function(){
        return this.invMax() - this.totalInvSize();
    }
    
    // Overwrite
    Theo.LINV.partyHasMaxItem = Game_Party.prototype.hasMaxItems;
    Game_Party.prototype.hasMaxItems = function(item) {
          if (DataManager.isBattleTest()){
            return Theo.LINV.partyHasMaxItem.call(this, item)
        }else{
            return this.isInvMaxed();
        };
    };
    
    Game_Party.prototype.isNearingMax = function(){
        return this.freeSlot() / this.invMax() <= Number(Theo.LINV.Params['nearMaxPercent'])/100
    }
    
    Game_Party.prototype.itemSize = function(item){
        if(!item){return 0};
        return item.invSize * this.numItems(item);
    }
    
    Game_Party.prototype.forceGainItem = function(item, amount, includeEquip){
        var container = this.itemContainer(item);
          if (container) {
            var lastNumber = this.numItems(item);
            var newNumber = lastNumber + amount;
            container[item.id] = Math.max(newNumber, 0);
            if (container[item.id] === 0) {
            delete container[item.id];
            }
            if (includeEquip && newNumber < 0) {
                  this.discardMembersEquip(item, -newNumber);
            }
            $gameMap.requestRefresh();
      }
    }
    
    // Overwrite
    Game_Party.prototype.loseItem = function(item, amount, includeEquip) {
        this.forceGainItem(item, -amount, includeEquip);
    };
    
    // Overwrite
    Theo.LINV.partyGainItem = Game_Party.prototype.gainItem;
    Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
        if(Theo.LINV.Params['forceGain'] === 'true'){
            Theo.LINV.partyGainItem.call(this, item, amount, includeEquip);
        }else{
            this.forceGainItem(item, amount, includeEquip);
        }
    };
    
    //===================================================================
    // ** Game_Player
    //===================================================================
    Theo.LINV.playerIsDashing = Game_Player.prototype.isDashing;
    Game_Player.prototype.isDashing = function() {
        if(Theo.LINV.Params['fullDisableDash'] === 'true' && $gameParty.isInvMaxed()){return false};
      return Theo.LINV.playerIsDashing.call(this);
    };
    
    // This need confirmation if it's okay
    Theo.LINV.playerRealSpeed = Game_CharacterBase.prototype.realMoveSpeed;
    Game_Player.prototype.realMoveSpeed = function() {
      return Theo.LINV.playerRealSpeed.call(this) - this.movePenalty();
    };
    
    Game_Player.prototype.movePenalty = function(){
        return (Theo.LINV.Params['fullSlowDown'] === 'true' && $gameParty.isInvMaxed() ? 1 : 0);
    }
    //===================================================================
    // ** Window_Base
    //===================================================================
    Window_Base.prototype.drawInvSlot = function(x, y, width, align = 'right'){
        let total = String($gameParty.totalInvSize());
        let invmax = String($gameParty.invMax());
        let txt = total + "/" + invmax;
        console.log(invmax);
        let colorId = Number(Theo.LINV.Params['nearMaxColor']);
        if ($gameParty.isNearingMax()){
            this.changeTextColor(this.textColor(colorId));
        }else{
            this.changeTextColor(this.normalColor());
        }
        this.drawText(txt,x,y,width,align)
      this.changeTextColor(this.normalColor())
    }
    
    Window_Base.prototype.drawInvInfo = function(x,y,width){
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSlotVocab'],x,y,width,0);
        this.changeTextColor(this.normalColor());
        this.drawInvSlot(x, y, width);
    }
    
    Window_Base.prototype.drawItemSize = function(item, x, y, width){
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSizeVocab'], x, y, width);
        this.changeTextColor(this.normalColor());
        // console.log($gameParty.itemSize(item));
        // console.log(item.invSize);
        let num = (Theo.LINV.Params['drawTotalSize'] === 'true') ? $gameParty.itemSize(item) : (!item ? 0 : item.invSize);
        // console.log(num);
        this.drawText(num, x, y, width, 'right');
    }
    //===================================================================
    // ** Limited Inventory - Window_MainMenu
    //===================================================================
    Theo.LINV.Window_MainMenu = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_MainMenu.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_MainMenu.prototype.constructor = Theo.LINV.Window_MainMenu;
    
    Theo.LINV.Window_MainMenu.prototype.initialize = function(width) {
      Window_Base.prototype.initialize.call(this,0,0,width,this.fittingHeight(1));
    };
    
    Theo.LINV.Window_MainMenu.prototype.refresh = function(){
        this.contents.clear();
        this.changeTextColor(this.systemColor());
        let txt = Theo.LINV.Params['slotShort'];
        this.drawText(txt, 0, 0, this.contents.width);
        this.drawInvSlot(0, 0, this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_ItemSize
    //===================================================================
    Theo.LINV.Window_ItemSize = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_ItemSize.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_ItemSize.prototype.constructor = Theo.LINV.Window_ItemSize;
    
    Theo.LINV.Window_ItemSize.prototype.initialize = function(x,y,width) {
      Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
    };
    
    Theo.LINV.Window_ItemSize.prototype.setItem = function(item) {
        this.item = item;
        this.refresh();
    }
    
    Theo.LINV.Window_ItemSize.prototype.refresh = function(){
        this.contents.clear();
        this.drawItemSize(this.item,0,0,this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_FreeSlot
    //===================================================================
    Theo.LINV.Window_FreeSlot = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_FreeSlot.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_FreeSlot.prototype.constructor = Theo.LINV.Window_FreeSlot;
    
    Theo.LINV.Window_FreeSlot.prototype.initialize = function(x,y,width) {
      Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
        this.refresh();
    };
    
    Theo.LINV.Window_FreeSlot.prototype.refresh = function(){
        this.contents.clear();
        this.drawInvInfo(0,0,this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_ItemUse
    //===================================================================
    Theo.LINV.Window_ItemUse = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_ItemUse.prototype = Object.create(Window_Command.prototype);
    Theo.LINV.Window_ItemUse.prototype.constructor = Theo.LINV.Window_ItemUse;
    
    Theo.LINV.Window_ItemUse.prototype.initialize = function(){
        Window_Command.prototype.initialize.call(this, 0, 0);
        this._openness = 0;
        this.deactivate();
    }
    
    Theo.LINV.Window_ItemUse.prototype.setItem = function(item){
        this._item = item;
        this.refresh();
    }
    
    Theo.LINV.Window_ItemUse.prototype.windowWidth = function() {
        return Number(Theo.LINV.Params[`commandSize`]);
    };
    
    Theo.LINV.Window_ItemUse.prototype.makeCommandList = function(){
        this.addCommand(Theo.LINV.Params['useVocab'], 'use', $gameParty.canUse(this._item));
        this.addCommand(Theo.LINV.Params['discardVocab'], 'discard', this.discardAble(this._item));
        this.addCommand(Theo.LINV.Params['cancelVocab'], 'cancel');
    }
    
    Theo.LINV.Window_ItemUse.prototype.toCenter = function(){
        this.x = Graphics.width/2 - this.width/2;
        this.y = Graphics.height/2 - this.height/2 - 20;
    }
    
    Theo.LINV.Window_ItemUse.prototype.discardAble = function(item){
        if(!item) {return false};
        if(Theo.LINV.Params['canDiscardItem'] === 'false') {return false}
        if(item.undiscardable) {return false;}
        if(item.itypeId) {return item.itypeId !== 2}
        else{return true};
    }
    //===================================================================
    // ** Limited Inventory - Window_Discard
    //===================================================================
    Theo.LINV.Window_Discard = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_Discard.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_Discard.prototype.constructor = Theo.LINV.Window_Discard;
    
    Theo.LINV.Window_Discard.prototype.initialize = function(x,y,width){
        Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
        this._openness = 0;
        this._amount = 0;
        this.setCursorRect(0, 0, this.contents.width, this.contents.height);
        this.active = true;
    }
    
    Theo.LINV.Window_Discard.prototype.setItem = function(item){
        this._item = item;
        this._amount = 0;
        this.refresh();
    }
    
    Theo.LINV.Window_Discard.prototype.refresh = function(){
        this.contents.clear();
        if(!this._item){return};
        this.drawItemName(this._item, 2, 2, this.contents.width);
        let txt = String(this._amount)+"/"+String($gameParty.numItems(this._item));
        this.drawText(txt,0,1,this.contents.width-2,'right')
    }
    
    Theo.LINV.Window_Discard.prototype.drawItemName = function(item, x, y, width){
        if(!item){return};
        this.drawIcon(item.iconIndex, x, y);
        this.drawText(item.name + ":",x + 36, y, width);
    }
    
    Theo.LINV.Window_Discard.prototype.update = function(){
        Window_Base.prototype.update.call(this);
        if (!this.isOpen()){return};
        if (Input.isRepeated('right')) {this.changeAmount(1)};
        if (Input.isRepeated('left')) {this.changeAmount(-1)};
        if (Input.isRepeated('up')) {this.changeAmount(10)};
        if (Input.isRepeated('down')) {this.changeAmount(-10)};
        if (Input.isTriggered('ok')){this.loseItem()};
        if (Input.isTriggered('cancel')){this.closeWindow()};
    }
    
    Theo.LINV.Window_Discard.prototype.changeAmount = function(amount){
        this._amount = (this._amount + amount).clamp(0,$gameParty.numItems(this._item));
        SoundManager.playCursor();
        this.refresh();
    }
    
    Theo.LINV.Window_Discard.prototype.loseItem = function(){
        $gameParty.loseItem(this._item,this._amount);
        this.itemList.redrawCurrentItem();
        this.freeSlot.refresh();
        if($gameParty.numItems(this._item) === 0){
            SoundManager.playOk();
            this.itemList.activate();
            this.itemList.refresh();
            this.itemList.updateHelp();
            this.commandWindow.close();
            this.commandWindow.deactivate();
            this.close();
        }else{
            this.closeWindow();
        }
    }
    
    Theo.LINV.Window_Discard.prototype.closeWindow = function(){
        this.close();
        this.commandWindow.activate();
        SoundManager.playOk();
    }
    //===================================================================
    // ** Default Script - Window_ItemList
    //===================================================================
    Window_ItemList.prototype.itemSizeWindow = function(w){
        this._itemSizeWindow = w;
        this._itemSizeWindow.setItem(this.item);
    }
    
    Theo.LINV.itemList_updateHelp = Window_ItemList.prototype.updateHelp;
    Window_ItemList.prototype.updateHelp = function(){
        Theo.LINV.itemList_updateHelp.call(this);
        if (!this._itemSizeWindow){return};
        this._itemSizeWindow.setItem(this.item());
    }
    
    Window_ItemList.prototype.changeHeight = function(height){
        this.height = height;
        this.refresh();
    }
    
    // Overwrite
    Window_ItemList.prototype.isEnabled = function(item) {
          if (item){return true}else{return false};
    };
    //===================================================================
    // ** Default Script - Window_ShopNumber
    //===================================================================
    Theo.LINV.shopNumInit = Window_ShopNumber.prototype.initialize;
    Window_ShopNumber.prototype.initialize = function(x,y,height){
        //Window_ShopNumber.prototype.initialize.call(this, x, y, height);
        Theo.LINV.shopNumInit.call(this, x, y, height);
        this._number = 0;
        this._mode = 'buy';
    }
    
    Theo.LINV.shopNumRefresh = Window_ShopNumber.prototype.refresh;
    Window_ShopNumber.prototype.refresh = function(){
        Theo.LINV.shopNumRefresh.call(this);
        this.drawItemSize();
    }
    
    Window_ShopNumber.prototype.lineHeight = function() {
        return Window_Base.prototype.lineHeight.call(this)
    };
    
    Window_ShopNumber.prototype.drawItemSize = function(){
        let num = this._number * $dataItems[this._item.id].invSize;
        let total = $gameParty.totalInvSize() + (this._mode === 'buy' ? num : num * -1);
        let txt = String(total)+"/"+String($gameParty.invMax());
        let ypos = this.itemY() + this.lineHeight() * 4;
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSlotVocab'],6,ypos,this.contents.width-12);
        this.changeTextColor(this.normalColor());
        this.drawText(txt,6,ypos,this.contents.width-12,'right');
    }
    
    //===================================================================
    // ** Default Script - Window_ShopStatus
    //===================================================================
    if (Theo.LINV.Params['displayItem'] === 'true'){
        Theo.LINV.shopStatusPossession = Window_ShopStatus.prototype.drawPossession;
        Window_ShopStatus.prototype.drawPossession = function(x, y){
            Theo.LINV.shopStatusPossession.call(this, x, y);
            y += this.lineHeight();
            this.drawItemSize(this._item, x, y, this.contents.width - (x*2));
        }
    }
    //===================================================================
    // ** Default Script - Scene_Menu
    //===================================================================
    Theo.LINV.sceneMenuCreate = Scene_Menu.prototype.create;
    Scene_Menu.prototype.create = function(){
        Theo.LINV.sceneMenuCreate.call(this);
        this.createLinvWindow();
    }
    
    Scene_Menu.prototype.createLinvWindow = function(){
        this._linvWindow = new Theo.LINV.Window_MainMenu(this._goldWindow.width);
        this._linvWindow.x = this._commandWindow.x;
        this._linvWindow.y = this._commandWindow.height;
        this._linvWindow.refresh();
        this.addWindow(this._linvWindow);
    }
    //===================================================================
    // ** Default Script - Scene_Item
    //===================================================================
    Theo.LINV.sceneItemCreate = Scene_Item.prototype.create;
    Scene_Item.prototype.create = function(){
        Theo.LINV.sceneItemCreate.call(this);
        this.resizeItemWindow();
        this.createUpperLayer();
        this.createFreeslotWindow();
        this.createItemsizeWindow();
        this.createUsecommandWindow();
        this.createDiscardAmount();
        this.reoderChilds();
    }
    
    Scene_Item.prototype.resizeItemWindow = function(){
        this._itemWindow.height -= this._itemWindow.lineHeight() * 2;
    }
    
    Scene_Item.prototype.reoderChilds = function(){
        this._windowLayer.children.findIndex(function(element){
            if (element === this._actorWindow){
                this._windowLayer.removeChild(element);
                this._windowLayer.addChild(element);
                return true;
            }
            return false;
        },this);
    }
    
    Scene_Item.prototype.createUpperLayer = function(){
        let width = Graphics.boxWidth;
        let height = Graphics.boxHeight;
        let x = (Graphics.width - width) / 2;
        let y = (Graphics.height - height) / 2;
        this._useLayer = new WindowLayer();
        this._useLayer.move(x, y, width, height);
        this.addChild(this._useLayer);
    }
    
    Scene_Item.prototype.addUpperWindow = function(w){
        this._useLayer.addChild(w);
    }
    
    Scene_Item.prototype.createFreeslotWindow = function(){
        let wy = this._itemWindow.y + this._itemWindow.height;
        let wh = Theo.LINV.Params['displayItem'] === 'true' ? Graphics.width/2 : Graphics.width;
        this._freeSlot = new Theo.LINV.Window_FreeSlot(0,wy,wh);
        this.addWindow(this._freeSlot);
    }
    
    Scene_Item.prototype.createItemsizeWindow = function(){
        if(Theo.LINV.Params['displayItem'] === 'false'){return};
        let wx = this._freeSlot.width
        let wy = this._freeSlot.y
        let ww = wx
        this._itemSize = new Theo.LINV.Window_ItemSize(wx,wy,ww)
        this._itemWindow._itemSizeWindow = this._itemSize
        this.addWindow(this._itemSize)
    }
    
    Scene_Item.prototype.createUsecommandWindow = function(){
        this._useCommand = new Theo.LINV.Window_ItemUse()
        this._useCommand.toCenter()
        this._useCommand.setHandler('use', this.useCommandOk.bind(this))
        this._useCommand.setHandler('discard', this.onDiscardOk.bind(this))
        this._useCommand.setHandler('cancel', this.onUseCancel.bind(this))
        this.addUpperWindow(this._useCommand)
    }
    
    Scene_Item.prototype.createDiscardAmount = function(){
        let wx = this._useCommand.x
        let wy = this._useCommand.y + this._useCommand.height
        let ww = this._useCommand.width
        this._discardWindow = new Theo.LINV.Window_Discard(wx,wy,ww)
        this._discardWindow.commandWindow = this._useCommand
        this._discardWindow.itemList = this._itemWindow
        this._discardWindow.freeSlot = this._freeSlot
        this.addUpperWindow(this._discardWindow)
    }
    
    // Overwrite
    Theo.LINV.sceneItem_OnItemOk = Scene_Item.prototype.onItemOk;
    Scene_Item.prototype.onItemOk = function(){
        this._useCommand.setItem(this.item())
        this._useCommand.open()
        this._useCommand.activate()
        this._useCommand.select(0)
    }
    
    Theo.LINV.sceneItem_UseItem = Scene_Item.prototype.useItem;
    Scene_Item.prototype.useItem = function(){
        this._useCommand.close()
        Theo.LINV.sceneItem_UseItem.call(this)
        this._freeSlot.refresh();
    }
    
    Scene_Item.prototype.useCommandOk = function(){
        Theo.LINV.sceneItem_OnItemOk.call(this);
        this._useCommand.close();
    }
    
    Scene_Item.prototype.onDiscardOk = function(){
        this._discardWindow.setItem(this.item())
        this._discardWindow.open()
    }
    
    Scene_Item.prototype.onUseCancel = function(){
        this._itemWindow.activate()
        this._useCommand.close()
        this._useCommand.deactivate()
    }
    
    //===================================================================
    //** Default Script - Scene_Shop
    //===================================================================
    Theo.LINV.shopBuyOk = Scene_Shop.prototype.onBuyOk;
    Scene_Shop.prototype.onBuyOk = function() {
        this._numberWindow._mode = 'buy';
        Theo.LINV.shopBuyOk.call(this);
    };
    
    Theo.LINV.shopSellOk = Scene_Shop.prototype.onSellOk;
    Scene_Shop.prototype.onSellOk = function() {
        this._numberWindow._mode = 'sell';
        Theo.LINV.shopSellOk.call(this);
    };
    Thankfully this fixed the shop issue I was having. How can I change the X and Y position of the weight window?
  15. ywh96 said:
    I fix some bugs and add small features.
    Hope this helps anyone.


    JavaScript:
    /*:
    @plugindesc Limits carrying capacity like in many popular games.
    Version 0.9
    @author TheoAllen
    @help
    This script allow you to limit your inventory by overall possesed
    items instead of individual items.
    
    IMPORTANT NOTE:
    Name the file of this plugin literally as
    "TheoLimitedInventory.js"
      
    Notetags :
    write down these notetags to the notebox in your database
        
    <inv size: n>
    Use this notetag where the n is a numeric value which is determine
    the size of item. Use 0 for unlimited item. Only works for item
    and equipment such as weapon or armor.
    
    <inv plus: n>
    Use this notetag to determine the additional avalaible free
    inventory slot. This notetag avalaible for Actor, Class, Equip,
    and States. If it's for actor, avalaible inventory slot will
    increase when a new actor entered party. If it's for equip, the
    avalaible slot will be increase if the certain equip is equipped.
    And so do states.
    
    This value can be changed by script call during the game. Just
    check the script call instruction.
    
    <inv minus: n>
    Inverse of <inv plus>. It will decrease the avalaible inventory
    slot. Should be self explanatory
    
    <undiscardable>
    Make an item undiscardable.
    
    TO DO LIST
    > Make it more touch input friendly
    > Add inventory slot eval formula
    > Maybe, some compatibility patch
    
    Terms of use :
    Credit me, TheoAllen. You are free to edit this script by your own.
    As long as you don't claim it yours. For commercial purpose, don't
    forget to give me a free copy of the game.
    
    @param Preferences
      
    @param dynamic
    @parent Preferences
    @text Dynamic Slot
    @type boolean
    @default true
    @desc If set to true, then total avalaible inventory slot depends on actor, states, total party members, etc ...
     
    @param displayItem
    @parent Preferences
    @text Display Item Size
    @type boolean
    @default true
    @desc Diplay item size in item menu
     
    @param includeEquip
    @parent Preferences
    @text Include Equip
    @type boolean
    @default false
    @desc Total used inventory slot will also include actor equipment.
    
    @param drawTotalSize
    @parent Preferences
    @text Draw Total Size
    @type boolean
    @default true
    @desc If true, item size window will show total weight of specified item. 10 potions with 3 weight each = show 30 instead of 3
    
    @param forceGain
    @parent Preferences
    @text Force Gain Item
    @type boolean
    @default false
    @desc Force gain item even if inventory full. (Recommended to set some penalties if inventory is full)
    
    @param fullDisableDash
    @parent Preferences
    @text Disable Dash at Full
    @type boolean
    @default false
    @desc When the inventory is at full, disable dashing
    
    @param fullSlowDown
    @parent Preferences
    @text Slowdowns at full
    @type boolean
    @default false
    @desc When the inventory is at full, slow down the movement
    
    @param canDiscardItem
    @parent Preferences
    @text canDiscardItem?
    @type boolean
    @default true
    @desc If set to false, the item discard feature is disabled.
    
    @param Numeric Setting
    
    @param defaultFree
    @parent Numeric Setting
    @text Default Free Slot
    @type number
    @default 20
    @desc Default free slot provided by each actor. If Dynamic slot set to false. It will be use this setting for the free slot
    
    @param nearMaxPercent
    @parent Numeric Setting
    @text Near Maximum Percentage
    @type number
    @default 25
    @desc Remain avalaible slot percentage to determine if the inventory is almost maxed out or not.
    
    @param nearMaxColor
    @parent Numeric Setting
    @text Near Maximum Color ID
    @type number
    @default 21
    @desc Color ID to draw the number
    
    @param commandSize
    @parent Numeric Setting
    @text Use Command Size
    @type number
    @default 340
    @desc The width of use item command window
    
    @param Vocab Settings
    
    @param invSlotVocab
    @parent Vocab Settings
    @text Inventory Slot
    @default Inventory:
    @desc Vocab for inventory
    
    @param invSizeVocab
    @parent Vocab Settings
    @text Size Vocab
    @default Size:
    @desc Vocab for Size
    
    @param slotShort
    @parent Vocab Settings
    @text Inventory Slot (Short)
    @default Inv:
    @desc Vocab for inventory (short)
    
    @param useVocab
    @parent Vocab Settings
    @text Use Vocab
    @default Use Item
    @desc Vocab for using an item
    
    @param discardVocab
    @parent Vocab Settings
    @text Discard Vocab
    @default Discard
    @desc Vocab for discarding an item
    
    @param cancelVocab
    @parent Vocab Settings
    @text Cancel Vocab
    @default Cancel
    @desc Vocab for canceling
    
     */
    var Theo = Theo || function(){ throw new Error('This is a static class')}
    Theo.LINV = {}
    Theo.LINV.Params = PluginManager.parameters('TheoLimitedInventory')
    
    Theo.LINV.invSizeREGX = /<inv[\s_]+size\s*:\s*(\d+)>/i
    Theo.LINV.invPlusREGX = /<inv[\s_]+plus\s*:\s*(\d+)>/i
    Theo.LINV.invMinsREGX = /<inv[\s_]+minus\s*:\s*(\d+)>/i
    Theo.LINV.undiscardableREGX = /<undiscardable>/i
    
    //===================================================================
    // ** DataManager
    //===================================================================
    Theo.LINV.dbLoaded = DataManager.isDatabaseLoaded;
    DataManager.isDatabaseLoaded = function(){
        if (!Theo.LINV.dbLoaded.call(this)) {return false};
        if (!Theo.LINV.invLoaded) {
            Theo.LINV.loadActorDefault($dataActors);
            let database =  [$dataActors, $dataClasses, $dataWeapons, $dataArmors, $dataStates, $dataItems];
            database.forEach(function(data){
                data.forEach(function(db){
                    if(db === null){return};
                    Theo.LINV.loadData(db);
                })
            })
            Theo.LINV.invLoaded = true;
        }
        return true;
    }
    
    Theo.LINV.loadActorDefault = function(actors){
        actors.forEach(function(actor){
            if(!actor){return};
            actor.invMod = Number(Theo.LINV.Params['defaultFree']);
        })
    }
    
    
    Theo.LINV.loadData = function(db){
        if (!db.invMod){db.invMod = 0};
        db.invSize = 1;
        db.undiscardable = false;
        let notedata = db.note.split(/[\r\n]+/);
        notedata.forEach(function(line){
            if(line.match(Theo.LINV.invSizeREGX)){
                db.invSize = Number(RegExp.$1);
            }else if(line.match(Theo.LINV.invPlusREGX)){
                db.invMod = Number(RegExp.$1);
            }else if(line.match(Theo.LINV.invMinsREGX)){
                db.invMod = Number(RegExp.$1) * -1;
            }else if(line.match(Theo.LINV.undiscardableREGX)){
                db.undiscardable = true;
            }
        });
    }
    
    //===================================================================
    // ** Game_Actor
    //===================================================================
    Theo.LINV.actorSetup = Game_Actor.prototype.setup;
    Game_Actor.prototype.setup = function(actorId) {
        Theo.LINV.actorSetup.call(this, actorId);
            var actor = $dataActors[actorId];
        this._baseInv = actor.invMod;
    };
    
    Game_Actor.prototype.getBaseInv = function(){
        if (!this._baseInv) return 0;
        return this._baseInv;
    }
    
    Game_Actor.prototype.setBaseInv = function(num){
        return this._baseInv = num;
    }
    
    Game_Actor.prototype.equipSize = function(){
        if (Theo.LINV.Params['includeEquip'] === 'false'){return 0};
        return this.equips().reduce(function(total, eq){
            if(eq === null){return total + 0};
            return total + eq.invSize;
        },0);
    }
    
    // TO DO = Add Eval
    Game_Actor.prototype.invMax = function(){
        var size = this.getBaseInv();
        size += $dataClasses[this._classId].invMod;
        //size += this.states().reduce(function(total, state){total + state.invMod}, 0);
        size += this.states().reduce(function(total, state){return total + state.invMod}, 0);
        size += this.equips().reduce(function(total, eq){
            if(!eq){return total + 0};
            return total + eq.invMod;
        },0);
        return Number(size);
    }
    
    // Overwrite
    Game_Actor.prototype.tradeItemWithParty = function(newItem, oldItem) {
          if (newItem && !$gameParty.hasItem(newItem)) {
                 return false;
          }else{
                 $gameParty.forceGainItem(oldItem, 1);
                 $gameParty.forceGainItem(newItem, -1);
                 return true;
          }
    };
    //===================================================================
    // ** Game_Party
    //===================================================================
    Theo.LINV.partyInit = Game_Party.prototype.initialize;
    Game_Party.prototype.initialize = function(){
        this._baseInv = (Theo.LINV.Params['dynamic'] === 'true' ? 0 : Number(Theo.LINV.Params['defaultFree']))
        Theo.LINV.partyInit.call(this);
    }
    
    Game_Party.prototype.getBaseInv = function(){
        return this._baseInv;
    }
    
    Game_Party.prototype.setBaseInv = function(num){
        return this._baseInv = num;
    }
    
    Game_Party.prototype.invMax = function(){
        if(Theo.LINV.Params['dynamic'] === 'false'){return this._baseInv};
        return this.members().reduce(function(total, member){
            return total + member.invMax();
        }, 0) + this._baseInv;
    }
    
    Game_Party.prototype.isInvMaxed = function(){
        return this.invMax() <= this.totalInvSize();
    }
    
    Game_Party.prototype.totalInvSize = function(){
        var numitem = this.numItems.bind(this);
        var size = this.allItems().reduce(function(total, item){
        if(!item){return total + 0};
            return total + item.invSize * numitem(item);
        },0);
        size += this.members().reduce(function(total, member){
            return total + member.equipSize();
        }, 0);
        return size
    }
    
    // Overwrite
    Theo.LINV.partyMaxItem = Game_Party.prototype.maxItems;
    Game_Party.prototype.maxItems = function(item) {
          if (DataManager.isBattleTest()){
            return Theo.LINV.partyMaxItem.call(this, item)
        }else{
            return this.invMaxItem(item) + this.numItems(item);
        };
    };
    
    Game_Party.prototype.invMaxItem = function(item){
        if(!item || item === null || item.invSize === 0){return 999999};
        return Math.floor(this.freeSlot() / item.invSize);
    }
    
    Game_Party.prototype.freeSlot = function(){
        return this.invMax() - this.totalInvSize();
    }
    
    // Overwrite
    Theo.LINV.partyHasMaxItem = Game_Party.prototype.hasMaxItems;
    Game_Party.prototype.hasMaxItems = function(item) {
          if (DataManager.isBattleTest()){
            return Theo.LINV.partyHasMaxItem.call(this, item)
        }else{
            return this.isInvMaxed();
        };
    };
    
    Game_Party.prototype.isNearingMax = function(){
        return this.freeSlot() / this.invMax() <= Number(Theo.LINV.Params['nearMaxPercent'])/100
    }
    
    Game_Party.prototype.itemSize = function(item){
        if(!item){return 0};
        return item.invSize * this.numItems(item);
    }
    
    Game_Party.prototype.forceGainItem = function(item, amount, includeEquip){
        var container = this.itemContainer(item);
          if (container) {
            var lastNumber = this.numItems(item);
            var newNumber = lastNumber + amount;
            container[item.id] = Math.max(newNumber, 0);
            if (container[item.id] === 0) {
            delete container[item.id];
            }
            if (includeEquip && newNumber < 0) {
                  this.discardMembersEquip(item, -newNumber);
            }
            $gameMap.requestRefresh();
      }
    }
    
    // Overwrite
    Game_Party.prototype.loseItem = function(item, amount, includeEquip) {
        this.forceGainItem(item, -amount, includeEquip);
    };
    
    // Overwrite
    Theo.LINV.partyGainItem = Game_Party.prototype.gainItem;
    Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
        if(Theo.LINV.Params['forceGain'] === 'true'){
            Theo.LINV.partyGainItem.call(this, item, amount, includeEquip);
        }else{
            this.forceGainItem(item, amount, includeEquip);
        }
    };
    
    //===================================================================
    // ** Game_Player
    //===================================================================
    Theo.LINV.playerIsDashing = Game_Player.prototype.isDashing;
    Game_Player.prototype.isDashing = function() {
        if(Theo.LINV.Params['fullDisableDash'] === 'true' && $gameParty.isInvMaxed()){return false};
      return Theo.LINV.playerIsDashing.call(this);
    };
    
    // This need confirmation if it's okay
    Theo.LINV.playerRealSpeed = Game_CharacterBase.prototype.realMoveSpeed;
    Game_Player.prototype.realMoveSpeed = function() {
      return Theo.LINV.playerRealSpeed.call(this) - this.movePenalty();
    };
    
    Game_Player.prototype.movePenalty = function(){
        return (Theo.LINV.Params['fullSlowDown'] === 'true' && $gameParty.isInvMaxed() ? 1 : 0);
    }
    //===================================================================
    // ** Window_Base
    //===================================================================
    Window_Base.prototype.drawInvSlot = function(x, y, width, align = 'right'){
        let total = String($gameParty.totalInvSize());
        let invmax = String($gameParty.invMax());
        let txt = total + "/" + invmax;
        console.log(invmax);
        let colorId = Number(Theo.LINV.Params['nearMaxColor']);
        if ($gameParty.isNearingMax()){
            this.changeTextColor(this.textColor(colorId));
        }else{
            this.changeTextColor(this.normalColor());
        }
        this.drawText(txt,x,y,width,align)
      this.changeTextColor(this.normalColor())
    }
    
    Window_Base.prototype.drawInvInfo = function(x,y,width){
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSlotVocab'],x,y,width,0);
        this.changeTextColor(this.normalColor());
        this.drawInvSlot(x, y, width);
    }
    
    Window_Base.prototype.drawItemSize = function(item, x, y, width){
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSizeVocab'], x, y, width);
        this.changeTextColor(this.normalColor());
        // console.log($gameParty.itemSize(item));
        // console.log(item.invSize);
        let num = (Theo.LINV.Params['drawTotalSize'] === 'true') ? $gameParty.itemSize(item) : (!item ? 0 : item.invSize);
        // console.log(num);
        this.drawText(num, x, y, width, 'right');
    }
    //===================================================================
    // ** Limited Inventory - Window_MainMenu
    //===================================================================
    Theo.LINV.Window_MainMenu = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_MainMenu.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_MainMenu.prototype.constructor = Theo.LINV.Window_MainMenu;
    
    Theo.LINV.Window_MainMenu.prototype.initialize = function(width) {
      Window_Base.prototype.initialize.call(this,0,0,width,this.fittingHeight(1));
    };
    
    Theo.LINV.Window_MainMenu.prototype.refresh = function(){
        this.contents.clear();
        this.changeTextColor(this.systemColor());
        let txt = Theo.LINV.Params['slotShort'];
        this.drawText(txt, 0, 0, this.contents.width);
        this.drawInvSlot(0, 0, this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_ItemSize
    //===================================================================
    Theo.LINV.Window_ItemSize = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_ItemSize.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_ItemSize.prototype.constructor = Theo.LINV.Window_ItemSize;
    
    Theo.LINV.Window_ItemSize.prototype.initialize = function(x,y,width) {
      Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
    };
    
    Theo.LINV.Window_ItemSize.prototype.setItem = function(item) {
        this.item = item;
        this.refresh();
    }
    
    Theo.LINV.Window_ItemSize.prototype.refresh = function(){
        this.contents.clear();
        this.drawItemSize(this.item,0,0,this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_FreeSlot
    //===================================================================
    Theo.LINV.Window_FreeSlot = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_FreeSlot.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_FreeSlot.prototype.constructor = Theo.LINV.Window_FreeSlot;
    
    Theo.LINV.Window_FreeSlot.prototype.initialize = function(x,y,width) {
      Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
        this.refresh();
    };
    
    Theo.LINV.Window_FreeSlot.prototype.refresh = function(){
        this.contents.clear();
        this.drawInvInfo(0,0,this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_ItemUse
    //===================================================================
    Theo.LINV.Window_ItemUse = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_ItemUse.prototype = Object.create(Window_Command.prototype);
    Theo.LINV.Window_ItemUse.prototype.constructor = Theo.LINV.Window_ItemUse;
    
    Theo.LINV.Window_ItemUse.prototype.initialize = function(){
        Window_Command.prototype.initialize.call(this, 0, 0);
        this._openness = 0;
        this.deactivate();
    }
    
    Theo.LINV.Window_ItemUse.prototype.setItem = function(item){
        this._item = item;
        this.refresh();
    }
    
    Theo.LINV.Window_ItemUse.prototype.windowWidth = function() {
        return Number(Theo.LINV.Params[`commandSize`]);
    };
    
    Theo.LINV.Window_ItemUse.prototype.makeCommandList = function(){
        this.addCommand(Theo.LINV.Params['useVocab'], 'use', $gameParty.canUse(this._item));
        this.addCommand(Theo.LINV.Params['discardVocab'], 'discard', this.discardAble(this._item));
        this.addCommand(Theo.LINV.Params['cancelVocab'], 'cancel');
    }
    
    Theo.LINV.Window_ItemUse.prototype.toCenter = function(){
        this.x = Graphics.width/2 - this.width/2;
        this.y = Graphics.height/2 - this.height/2 - 20;
    }
    
    Theo.LINV.Window_ItemUse.prototype.discardAble = function(item){
        if(!item) {return false};
        if(Theo.LINV.Params['canDiscardItem'] === 'false') {return false}
        if(item.undiscardable) {return false;}
        if(item.itypeId) {return item.itypeId !== 2}
        else{return true};
    }
    //===================================================================
    // ** Limited Inventory - Window_Discard
    //===================================================================
    Theo.LINV.Window_Discard = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_Discard.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_Discard.prototype.constructor = Theo.LINV.Window_Discard;
    
    Theo.LINV.Window_Discard.prototype.initialize = function(x,y,width){
        Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
        this._openness = 0;
        this._amount = 0;
        this.setCursorRect(0, 0, this.contents.width, this.contents.height);
        this.active = true;
    }
    
    Theo.LINV.Window_Discard.prototype.setItem = function(item){
        this._item = item;
        this._amount = 0;
        this.refresh();
    }
    
    Theo.LINV.Window_Discard.prototype.refresh = function(){
        this.contents.clear();
        if(!this._item){return};
        this.drawItemName(this._item, 2, 2, this.contents.width);
        let txt = String(this._amount)+"/"+String($gameParty.numItems(this._item));
        this.drawText(txt,0,1,this.contents.width-2,'right')
    }
    
    Theo.LINV.Window_Discard.prototype.drawItemName = function(item, x, y, width){
        if(!item){return};
        this.drawIcon(item.iconIndex, x, y);
        this.drawText(item.name + ":",x + 36, y, width);
    }
    
    Theo.LINV.Window_Discard.prototype.update = function(){
        Window_Base.prototype.update.call(this);
        if (!this.isOpen()){return};
        if (Input.isRepeated('right')) {this.changeAmount(1)};
        if (Input.isRepeated('left')) {this.changeAmount(-1)};
        if (Input.isRepeated('up')) {this.changeAmount(10)};
        if (Input.isRepeated('down')) {this.changeAmount(-10)};
        if (Input.isTriggered('ok')){this.loseItem()};
        if (Input.isTriggered('cancel')){this.closeWindow()};
    }
    
    Theo.LINV.Window_Discard.prototype.changeAmount = function(amount){
        this._amount = (this._amount + amount).clamp(0,$gameParty.numItems(this._item));
        SoundManager.playCursor();
        this.refresh();
    }
    
    Theo.LINV.Window_Discard.prototype.loseItem = function(){
        $gameParty.loseItem(this._item,this._amount);
        this.itemList.redrawCurrentItem();
        this.freeSlot.refresh();
        if($gameParty.numItems(this._item) === 0){
            SoundManager.playOk();
            this.itemList.activate();
            this.itemList.refresh();
            this.itemList.updateHelp();
            this.commandWindow.close();
            this.commandWindow.deactivate();
            this.close();
        }else{
            this.closeWindow();
        }
    }
    
    Theo.LINV.Window_Discard.prototype.closeWindow = function(){
        this.close();
        this.commandWindow.activate();
        SoundManager.playOk();
    }
    //===================================================================
    // ** Default Script - Window_ItemList
    //===================================================================
    Window_ItemList.prototype.itemSizeWindow = function(w){
        this._itemSizeWindow = w;
        this._itemSizeWindow.setItem(this.item);
    }
    
    Theo.LINV.itemList_updateHelp = Window_ItemList.prototype.updateHelp;
    Window_ItemList.prototype.updateHelp = function(){
        Theo.LINV.itemList_updateHelp.call(this);
        if (!this._itemSizeWindow){return};
        this._itemSizeWindow.setItem(this.item());
    }
    
    Window_ItemList.prototype.changeHeight = function(height){
        this.height = height;
        this.refresh();
    }
    
    // Overwrite
    Window_ItemList.prototype.isEnabled = function(item) {
          if (item){return true}else{return false};
    };
    //===================================================================
    // ** Default Script - Window_ShopNumber
    //===================================================================
    Theo.LINV.shopNumInit = Window_ShopNumber.prototype.initialize;
    Window_ShopNumber.prototype.initialize = function(x,y,height){
        //Window_ShopNumber.prototype.initialize.call(this, x, y, height);
        Theo.LINV.shopNumInit.call(this, x, y, height);
        this._number = 0;
        this._mode = 'buy';
    }
    
    Theo.LINV.shopNumRefresh = Window_ShopNumber.prototype.refresh;
    Window_ShopNumber.prototype.refresh = function(){
        Theo.LINV.shopNumRefresh.call(this);
        this.drawItemSize();
    }
    
    Window_ShopNumber.prototype.lineHeight = function() {
        return Window_Base.prototype.lineHeight.call(this)
    };
    
    Window_ShopNumber.prototype.drawItemSize = function(){
        let num = this._number * $dataItems[this._item.id].invSize;
        let total = $gameParty.totalInvSize() + (this._mode === 'buy' ? num : num * -1);
        let txt = String(total)+"/"+String($gameParty.invMax());
        let ypos = this.itemY() + this.lineHeight() * 4;
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSlotVocab'],6,ypos,this.contents.width-12);
        this.changeTextColor(this.normalColor());
        this.drawText(txt,6,ypos,this.contents.width-12,'right');
    }
    
    //===================================================================
    // ** Default Script - Window_ShopStatus
    //===================================================================
    if (Theo.LINV.Params['displayItem'] === 'true'){
        Theo.LINV.shopStatusPossession = Window_ShopStatus.prototype.drawPossession;
        Window_ShopStatus.prototype.drawPossession = function(x, y){
            Theo.LINV.shopStatusPossession.call(this, x, y);
            y += this.lineHeight();
            this.drawItemSize(this._item, x, y, this.contents.width - (x*2));
        }
    }
    //===================================================================
    // ** Default Script - Scene_Menu
    //===================================================================
    Theo.LINV.sceneMenuCreate = Scene_Menu.prototype.create;
    Scene_Menu.prototype.create = function(){
        Theo.LINV.sceneMenuCreate.call(this);
        this.createLinvWindow();
    }
    
    Scene_Menu.prototype.createLinvWindow = function(){
        this._linvWindow = new Theo.LINV.Window_MainMenu(this._goldWindow.width);
        this._linvWindow.x = this._commandWindow.x;
        this._linvWindow.y = this._commandWindow.height;
        this._linvWindow.refresh();
        this.addWindow(this._linvWindow);
    }
    //===================================================================
    // ** Default Script - Scene_Item
    //===================================================================
    Theo.LINV.sceneItemCreate = Scene_Item.prototype.create;
    Scene_Item.prototype.create = function(){
        Theo.LINV.sceneItemCreate.call(this);
        this.resizeItemWindow();
        this.createUpperLayer();
        this.createFreeslotWindow();
        this.createItemsizeWindow();
        this.createUsecommandWindow();
        this.createDiscardAmount();
        this.reoderChilds();
    }
    
    Scene_Item.prototype.resizeItemWindow = function(){
        this._itemWindow.height -= this._itemWindow.lineHeight() * 2;
    }
    
    Scene_Item.prototype.reoderChilds = function(){
        this._windowLayer.children.findIndex(function(element){
            if (element === this._actorWindow){
                this._windowLayer.removeChild(element);
                this._windowLayer.addChild(element);
                return true;
            }
            return false;
        },this);
    }
    
    Scene_Item.prototype.createUpperLayer = function(){
        let width = Graphics.boxWidth;
        let height = Graphics.boxHeight;
        let x = (Graphics.width - width) / 2;
        let y = (Graphics.height - height) / 2;
        this._useLayer = new WindowLayer();
        this._useLayer.move(x, y, width, height);
        this.addChild(this._useLayer);
    }
    
    Scene_Item.prototype.addUpperWindow = function(w){
        this._useLayer.addChild(w);
    }
    
    Scene_Item.prototype.createFreeslotWindow = function(){
        let wy = this._itemWindow.y + this._itemWindow.height;
        let wh = Theo.LINV.Params['displayItem'] === 'true' ? Graphics.width/2 : Graphics.width;
        this._freeSlot = new Theo.LINV.Window_FreeSlot(0,wy,wh);
        this.addWindow(this._freeSlot);
    }
    
    Scene_Item.prototype.createItemsizeWindow = function(){
        if(Theo.LINV.Params['displayItem'] === 'false'){return};
        let wx = this._freeSlot.width
        let wy = this._freeSlot.y
        let ww = wx
        this._itemSize = new Theo.LINV.Window_ItemSize(wx,wy,ww)
        this._itemWindow._itemSizeWindow = this._itemSize
        this.addWindow(this._itemSize)
    }
    
    Scene_Item.prototype.createUsecommandWindow = function(){
        this._useCommand = new Theo.LINV.Window_ItemUse()
        this._useCommand.toCenter()
        this._useCommand.setHandler('use', this.useCommandOk.bind(this))
        this._useCommand.setHandler('discard', this.onDiscardOk.bind(this))
        this._useCommand.setHandler('cancel', this.onUseCancel.bind(this))
        this.addUpperWindow(this._useCommand)
    }
    
    Scene_Item.prototype.createDiscardAmount = function(){
        let wx = this._useCommand.x
        let wy = this._useCommand.y + this._useCommand.height
        let ww = this._useCommand.width
        this._discardWindow = new Theo.LINV.Window_Discard(wx,wy,ww)
        this._discardWindow.commandWindow = this._useCommand
        this._discardWindow.itemList = this._itemWindow
        this._discardWindow.freeSlot = this._freeSlot
        this.addUpperWindow(this._discardWindow)
    }
    
    // Overwrite
    Theo.LINV.sceneItem_OnItemOk = Scene_Item.prototype.onItemOk;
    Scene_Item.prototype.onItemOk = function(){
        this._useCommand.setItem(this.item())
        this._useCommand.open()
        this._useCommand.activate()
        this._useCommand.select(0)
    }
    
    Theo.LINV.sceneItem_UseItem = Scene_Item.prototype.useItem;
    Scene_Item.prototype.useItem = function(){
        this._useCommand.close()
        Theo.LINV.sceneItem_UseItem.call(this)
        this._freeSlot.refresh();
    }
    
    Scene_Item.prototype.useCommandOk = función(){
    Theo.LINV.sceneItem_OnItemOk.call(esto);
    this._useCommand.cerrar();
    }
    
    Scene_Item.prototype.onDiscardOk = función(){
        this._discardWindow.setItem(this.item())
    this._discardWindow.abrir()
    }
    
    Scene_Item.prototype.onUseCancel = función(){
    this._itemWindow.activar()
    this._useCommand.cerrar()
    this._useCommand.desactivar()
    }
    
    //===================================================================
    ** Script predeterminado - Scene_Shop
    //===================================================================
    Theo.LINV.shopBuyOk = Scene_Shop.prototype.onBuyOk;
    Scene_Shop.prototype.onBuyOk = función() {
    this._numberWindow._mode = 'comprar';
    Theo.LINV.shopBuyOk.call(esto);
    };
    
    Theo.LINV.shopSellOk = Scene_Shop.prototype.onSellOk;
    Scene_Shop.prototype.onSellOk = función() {
    this._numberWindow._mode = 'vender';
        Theo.LINV.shopSellOk.call(this);
    }; [/CÓDIGO]
    [/QUOTE]
    cias amigo, este es el mejor plugincomo grMucho

    ywh96 said:
    I fix some bugs and add small features.
    Hope this helps anyone.


    JavaScript:
    /*:
    @plugindesc Limits carrying capacity like in many popular games.
    Version 0.9
    @author TheoAllen
    @help
    This script allow you to limit your inventory by overall possesed
    items instead of individual items.
    
    IMPORTANT NOTE:
    Name the file of this plugin literally as
    "TheoLimitedInventory.js"
       
    Notetags :
    write down these notetags to the notebox in your database
         
    <inv size: n>
    Use this notetag where the n is a numeric value which is determine
    the size of item. Use 0 for unlimited item. Only works for item
    and equipment such as weapon or armor.
    
    <inv plus: n>
    Use this notetag to determine the additional avalaible free
    inventory slot. This notetag avalaible for Actor, Class, Equip,
    and States. If it's for actor, avalaible inventory slot will
    increase when a new actor entered party. If it's for equip, the
    avalaible slot will be increase if the certain equip is equipped.
    And so do states.
    
    This value can be changed by script call during the game. Just
    check the script call instruction.
    
    <inv minus: n>
    Inverse of <inv plus>. It will decrease the avalaible inventory
    slot. Should be self explanatory
    
    <undiscardable>
    Make an item undiscardable.
    
    TO DO LIST
    > Make it more touch input friendly
    > Add inventory slot eval formula
    > Maybe, some compatibility patch
    
    Terms of use :
    Credit me, TheoAllen. You are free to edit this script by your own.
    As long as you don't claim it yours. For commercial purpose, don't
    forget to give me a free copy of the game.
    
    @param Preferences
       
    @param dynamic
    @parent Preferences
    @text Dynamic Slot
    @type boolean
    @default true
    @desc If set to true, then total avalaible inventory slot depends on actor, states, total party members, etc ...
     
    @param displayItem
    @parent Preferences
    @text Display Item Size
    @type boolean
    @default true
    @desc Diplay item size in item menu
     
    @param includeEquip
    @parent Preferences
    @text Include Equip
    @type boolean
    @default false
    @desc Total used inventory slot will also include actor equipment.
    
    @param drawTotalSize
    @parent Preferences
    @text Draw Total Size
    @type boolean
    @default true
    @desc If true, item size window will show total weight of specified item. 10 potions with 3 weight each = show 30 instead of 3
    
    @param forceGain
    @parent Preferences
    @text Force Gain Item
    @type boolean
    @default false
    @desc Force gain item even if inventory full. (Recommended to set some penalties if inventory is full)
    
    @param fullDisableDash
    @parent Preferences
    @text Disable Dash at Full
    @type boolean
    @default false
    @desc When the inventory is at full, disable dashing
    
    @param fullSlowDown
    @parent Preferences
    @text Slowdowns at full
    @type boolean
    @default false
    @desc When the inventory is at full, slow down the movement
    
    @param canDiscardItem
    @parent Preferences
    @text canDiscardItem?
    @type boolean
    @default true
    @desc If set to false, the item discard feature is disabled.
    
    @param Numeric Setting
    
    @param defaultFree
    @parent Numeric Setting
    @text Default Free Slot
    @type number
    @default 20
    @desc Default free slot provided by each actor. If Dynamic slot set to false. It will be use this setting for the free slot
    
    @param nearMaxPercent
    @parent Numeric Setting
    @text Near Maximum Percentage
    @type number
    @default 25
    @desc Remain avalaible slot percentage to determine if the inventory is almost maxed out or not.
    
    @param nearMaxColor
    @parent Numeric Setting
    @text Near Maximum Color ID
    @type number
    @default 21
    @desc Color ID to draw the number
    
    @param commandSize
    @parent Numeric Setting
    @text Use Command Size
    @type number
    @default 340
    @desc The width of use item command window
    
    @param Vocab Settings
    
    @param invSlotVocab
    @parent Vocab Settings
    @text Inventory Slot
    @default Inventory:
    @desc Vocab for inventory
    
    @param invSizeVocab
    @parent Vocab Settings
    @text Size Vocab
    @default Size:
    @desc Vocab for Size
    
    @param slotShort
    @parent Vocab Settings
    @text Inventory Slot (Short)
    @default Inv:
    @desc Vocab for inventory (short)
    
    @param useVocab
    @parent Vocab Settings
    @text Use Vocab
    @default Use Item
    @desc Vocab for using an item
    
    @param discardVocab
    @parent Vocab Settings
    @text Discard Vocab
    @default Discard
    @desc Vocab for discarding an item
    
    @param cancelVocab
    @parent Vocab Settings
    @text Cancel Vocab
    @default Cancel
    @desc Vocab for canceling
    
     */
    var Theo = Theo || function(){ throw new Error('This is a static class')}
    Theo.LINV = {}
    Theo.LINV.Params = PluginManager.parameters('TheoLimitedInventory')
    
    Theo.LINV.invSizeREGX = /<inv[\s_]+size\s*:\s*(\d+)>/i
    Theo.LINV.invPlusREGX = /<inv[\s_]+plus\s*:\s*(\d+)>/i
    Theo.LINV.invMinsREGX = /<inv[\s_]+minus\s*:\s*(\d+)>/i
    Theo.LINV.undiscardableREGX = /<undiscardable>/i
    
    //===================================================================
    // ** DataManager
    //===================================================================
    Theo.LINV.dbLoaded = DataManager.isDatabaseLoaded;
    DataManager.isDatabaseLoaded = function(){
        if (!Theo.LINV.dbLoaded.call(this)) {return false};
        if (!Theo.LINV.invLoaded) {
            Theo.LINV.loadActorDefault($dataActors);
            let database =  [$dataActors, $dataClasses, $dataWeapons, $dataArmors, $dataStates, $dataItems];
            database.forEach(function(data){
                data.forEach(function(db){
                    if(db === null){return};
                    Theo.LINV.loadData(db);
                })
            })
            Theo.LINV.invLoaded = true;
        }
        return true;
    }
    
    Theo.LINV.loadActorDefault = function(actors){
        actors.forEach(function(actor){
            if(!actor){return};
            actor.invMod = Number(Theo.LINV.Params['defaultFree']);
        })
    }
    
    
    Theo.LINV.loadData = function(db){
        if (!db.invMod){db.invMod = 0};
        db.invSize = 1;
        db.undiscardable = false;
        let notedata = db.note.split(/[\r\n]+/);
        notedata.forEach(function(line){
            if(line.match(Theo.LINV.invSizeREGX)){
                db.invSize = Number(RegExp.$1);
            }else if(line.match(Theo.LINV.invPlusREGX)){
                db.invMod = Number(RegExp.$1);
            }else if(line.match(Theo.LINV.invMinsREGX)){
                db.invMod = Number(RegExp.$1) * -1;
            }else if(line.match(Theo.LINV.undiscardableREGX)){
                db.undiscardable = true;
            }
        });
    }
    
    //===================================================================
    // ** Game_Actor
    //===================================================================
    Theo.LINV.actorSetup = Game_Actor.prototype.setup;
    Game_Actor.prototype.setup = function(actorId) {
        Theo.LINV.actorSetup.call(this, actorId);
            var actor = $dataActors[actorId];
        this._baseInv = actor.invMod;
    };
    
    Game_Actor.prototype.getBaseInv = function(){
        if (!this._baseInv) return 0;
        return this._baseInv;
    }
    
    Game_Actor.prototype.setBaseInv = function(num){
        return this._baseInv = num;
    }
    
    Game_Actor.prototype.equipSize = function(){
        if (Theo.LINV.Params['includeEquip'] === 'false'){return 0};
        return this.equips().reduce(function(total, eq){
            if(eq === null){return total + 0};
            return total + eq.invSize;
        },0);
    }
    
    // TO DO = Add Eval
    Game_Actor.prototype.invMax = function(){
        var size = this.getBaseInv();
        size += $dataClasses[this._classId].invMod;
        //size += this.states().reduce(function(total, state){total + state.invMod}, 0);
        size += this.states().reduce(function(total, state){return total + state.invMod}, 0);
        size += this.equips().reduce(function(total, eq){
            if(!eq){return total + 0};
            return total + eq.invMod;
        },0);
        return Number(size);
    }
    
    // Overwrite
    Game_Actor.prototype.tradeItemWithParty = function(newItem, oldItem) {
          if (newItem && !$gameParty.hasItem(newItem)) {
                 return false;
          }else{
                 $gameParty.forceGainItem(oldItem, 1);
                 $gameParty.forceGainItem(newItem, -1);
                 return true;
          }
    };
    //===================================================================
    // ** Game_Party
    //===================================================================
    Theo.LINV.partyInit = Game_Party.prototype.initialize;
    Game_Party.prototype.initialize = function(){
        this._baseInv = (Theo.LINV.Params['dynamic'] === 'true' ? 0 : Number(Theo.LINV.Params['defaultFree']))
        Theo.LINV.partyInit.call(this);
    }
    
    Game_Party.prototype.getBaseInv = function(){
        return this._baseInv;
    }
    
    Game_Party.prototype.setBaseInv = function(num){
        return this._baseInv = num;
    }
    
    Game_Party.prototype.invMax = function(){
        if(Theo.LINV.Params['dynamic'] === 'false'){return this._baseInv};
        return this.members().reduce(function(total, member){
            return total + member.invMax();
        }, 0) + this._baseInv;
    }
    
    Game_Party.prototype.isInvMaxed = function(){
        return this.invMax() <= this.totalInvSize();
    }
    
    Game_Party.prototype.totalInvSize = function(){
        var numitem = this.numItems.bind(this);
        var size = this.allItems().reduce(function(total, item){
        if(!item){return total + 0};
            return total + item.invSize * numitem(item);
        },0);
        size += this.members().reduce(function(total, member){
            return total + member.equipSize();
        }, 0);
        return size
    }
    
    // Overwrite
    Theo.LINV.partyMaxItem = Game_Party.prototype.maxItems;
    Game_Party.prototype.maxItems = function(item) {
          if (DataManager.isBattleTest()){
            return Theo.LINV.partyMaxItem.call(this, item)
        }else{
            return this.invMaxItem(item) + this.numItems(item);
        };
    };
    
    Game_Party.prototype.invMaxItem = function(item){
        if(!item || item === null || item.invSize === 0){return 999999};
        return Math.floor(this.freeSlot() / item.invSize);
    }
    
    Game_Party.prototype.freeSlot = function(){
        return this.invMax() - this.totalInvSize();
    }
    
    // Overwrite
    Theo.LINV.partyHasMaxItem = Game_Party.prototype.hasMaxItems;
    Game_Party.prototype.hasMaxItems = function(item) {
          if (DataManager.isBattleTest()){
            return Theo.LINV.partyHasMaxItem.call(this, item)
        }else{
            return this.isInvMaxed();
        };
    };
    
    Game_Party.prototype.isNearingMax = function(){
        return this.freeSlot() / this.invMax() <= Number(Theo.LINV.Params['nearMaxPercent'])/100
    }
    
    Game_Party.prototype.itemSize = function(item){
        if(!item){return 0};
        return item.invSize * this.numItems(item);
    }
    
    Game_Party.prototype.forceGainItem = function(item, amount, includeEquip){
        var container = this.itemContainer(item);
          if (container) {
            var lastNumber = this.numItems(item);
            var newNumber = lastNumber + amount;
            container[item.id] = Math.max(newNumber, 0);
            if (container[item.id] === 0) {
            delete container[item.id];
            }
            if (includeEquip && newNumber < 0) {
                  this.discardMembersEquip(item, -newNumber);
            }
            $gameMap.requestRefresh();
      }
    }
    
    // Overwrite
    Game_Party.prototype.loseItem = function(item, amount, includeEquip) {
        this.forceGainItem(item, -amount, includeEquip);
    };
    
    // Overwrite
    Theo.LINV.partyGainItem = Game_Party.prototype.gainItem;
    Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
        if(Theo.LINV.Params['forceGain'] === 'true'){
            Theo.LINV.partyGainItem.call(this, item, amount, includeEquip);
        }else{
            this.forceGainItem(item, amount, includeEquip);
        }
    };
    
    //===================================================================
    // ** Game_Player
    //===================================================================
    Theo.LINV.playerIsDashing = Game_Player.prototype.isDashing;
    Game_Player.prototype.isDashing = function() {
        if(Theo.LINV.Params['fullDisableDash'] === 'true' && $gameParty.isInvMaxed()){return false};
      return Theo.LINV.playerIsDashing.call(this);
    };
    
    // This need confirmation if it's okay
    Theo.LINV.playerRealSpeed = Game_CharacterBase.prototype.realMoveSpeed;
    Game_Player.prototype.realMoveSpeed = function() {
      return Theo.LINV.playerRealSpeed.call(this) - this.movePenalty();
    };
    
    Game_Player.prototype.movePenalty = function(){
        return (Theo.LINV.Params['fullSlowDown'] === 'true' && $gameParty.isInvMaxed() ? 1 : 0);
    }
    //===================================================================
    // ** Window_Base
    //===================================================================
    Window_Base.prototype.drawInvSlot = function(x, y, width, align = 'right'){
        let total = String($gameParty.totalInvSize());
        let invmax = String($gameParty.invMax());
        let txt = total + "/" + invmax;
        console.log(invmax);
        let colorId = Number(Theo.LINV.Params['nearMaxColor']);
        if ($gameParty.isNearingMax()){
            this.changeTextColor(this.textColor(colorId));
        }else{
            this.changeTextColor(this.normalColor());
        }
        this.drawText(txt,x,y,width,align)
      this.changeTextColor(this.normalColor())
    }
    
    Window_Base.prototype.drawInvInfo = function(x,y,width){
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSlotVocab'],x,y,width,0);
        this.changeTextColor(this.normalColor());
        this.drawInvSlot(x, y, width);
    }
    
    Window_Base.prototype.drawItemSize = function(item, x, y, width){
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSizeVocab'], x, y, width);
        this.changeTextColor(this.normalColor());
        // console.log($gameParty.itemSize(item));
        // console.log(item.invSize);
        let num = (Theo.LINV.Params['drawTotalSize'] === 'true') ? $gameParty.itemSize(item) : (!item ? 0 : item.invSize);
        // console.log(num);
        this.drawText(num, x, y, width, 'right');
    }
    //===================================================================
    // ** Limited Inventory - Window_MainMenu
    //===================================================================
    Theo.LINV.Window_MainMenu = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_MainMenu.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_MainMenu.prototype.constructor = Theo.LINV.Window_MainMenu;
    
    Theo.LINV.Window_MainMenu.prototype.initialize = function(width) {
      Window_Base.prototype.initialize.call(this,0,0,width,this.fittingHeight(1));
    };
    
    Theo.LINV.Window_MainMenu.prototype.refresh = function(){
        this.contents.clear();
        this.changeTextColor(this.systemColor());
        let txt = Theo.LINV.Params['slotShort'];
        this.drawText(txt, 0, 0, this.contents.width);
        this.drawInvSlot(0, 0, this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_ItemSize
    //===================================================================
    Theo.LINV.Window_ItemSize = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_ItemSize.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_ItemSize.prototype.constructor = Theo.LINV.Window_ItemSize;
    
    Theo.LINV.Window_ItemSize.prototype.initialize = function(x,y,width) {
      Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
    };
    
    Theo.LINV.Window_ItemSize.prototype.setItem = function(item) {
        this.item = item;
        this.refresh();
    }
    
    Theo.LINV.Window_ItemSize.prototype.refresh = function(){
        this.contents.clear();
        this.drawItemSize(this.item,0,0,this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_FreeSlot
    //===================================================================
    Theo.LINV.Window_FreeSlot = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_FreeSlot.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_FreeSlot.prototype.constructor = Theo.LINV.Window_FreeSlot;
    
    Theo.LINV.Window_FreeSlot.prototype.initialize = function(x,y,width) {
      Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
        this.refresh();
    };
    
    Theo.LINV.Window_FreeSlot.prototype.refresh = function(){
        this.contents.clear();
        this.drawInvInfo(0,0,this.contents.width);
    }
    //===================================================================
    // ** Limited Inventory - Window_ItemUse
    //===================================================================
    Theo.LINV.Window_ItemUse = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_ItemUse.prototype = Object.create(Window_Command.prototype);
    Theo.LINV.Window_ItemUse.prototype.constructor = Theo.LINV.Window_ItemUse;
    
    Theo.LINV.Window_ItemUse.prototype.initialize = function(){
        Window_Command.prototype.initialize.call(this, 0, 0);
        this._openness = 0;
        this.deactivate();
    }
    
    Theo.LINV.Window_ItemUse.prototype.setItem = function(item){
        this._item = item;
        this.refresh();
    }
    
    Theo.LINV.Window_ItemUse.prototype.windowWidth = function() {
        return Number(Theo.LINV.Params[`commandSize`]);
    };
    
    Theo.LINV.Window_ItemUse.prototype.makeCommandList = function(){
        this.addCommand(Theo.LINV.Params['useVocab'], 'use', $gameParty.canUse(this._item));
        this.addCommand(Theo.LINV.Params['discardVocab'], 'discard', this.discardAble(this._item));
        this.addCommand(Theo.LINV.Params['cancelVocab'], 'cancel');
    }
    
    Theo.LINV.Window_ItemUse.prototype.toCenter = function(){
        this.x = Graphics.width/2 - this.width/2;
        this.y = Graphics.height/2 - this.height/2 - 20;
    }
    
    Theo.LINV.Window_ItemUse.prototype.discardAble = function(item){
        if(!item) {return false};
        if(Theo.LINV.Params['canDiscardItem'] === 'false') {return false}
        if(item.undiscardable) {return false;}
        if(item.itypeId) {return item.itypeId !== 2}
        else{return true};
    }
    //===================================================================
    // ** Limited Inventory - Window_Discard
    //===================================================================
    Theo.LINV.Window_Discard = function(){
        this.initialize.apply(this, arguments);
    }
    
    Theo.LINV.Window_Discard.prototype = Object.create(Window_Base.prototype);
    Theo.LINV.Window_Discard.prototype.constructor = Theo.LINV.Window_Discard;
    
    Theo.LINV.Window_Discard.prototype.initialize = function(x,y,width){
        Window_Base.prototype.initialize.call(this,x,y,width,this.fittingHeight(1));
        this._openness = 0;
        this._amount = 0;
        this.setCursorRect(0, 0, this.contents.width, this.contents.height);
        this.active = true;
    }
    
    Theo.LINV.Window_Discard.prototype.setItem = function(item){
        this._item = item;
        this._amount = 0;
        this.refresh();
    }
    
    Theo.LINV.Window_Discard.prototype.refresh = function(){
        this.contents.clear();
        if(!this._item){return};
        this.drawItemName(this._item, 2, 2, this.contents.width);
        let txt = String(this._amount)+"/"+String($gameParty.numItems(this._item));
        this.drawText(txt,0,1,this.contents.width-2,'right')
    }
    
    Theo.LINV.Window_Discard.prototype.drawItemName = function(item, x, y, width){
        if(!item){return};
        this.drawIcon(item.iconIndex, x, y);
        this.drawText(item.name + ":",x + 36, y, width);
    }
    
    Theo.LINV.Window_Discard.prototype.update = function(){
        Window_Base.prototype.update.call(this);
        if (!this.isOpen()){return};
        if (Input.isRepeated('right')) {this.changeAmount(1)};
        if (Input.isRepeated('left')) {this.changeAmount(-1)};
        if (Input.isRepeated('up')) {this.changeAmount(10)};
        if (Input.isRepeated('down')) {this.changeAmount(-10)};
        if (Input.isTriggered('ok')){this.loseItem()};
        if (Input.isTriggered('cancel')){this.closeWindow()};
    }
    
    Theo.LINV.Window_Discard.prototype.changeAmount = function(amount){
        this._amount = (this._amount + amount).clamp(0,$gameParty.numItems(this._item));
        SoundManager.playCursor();
        this.refresh();
    }
    
    Theo.LINV.Window_Discard.prototype.loseItem = function(){
        $gameParty.loseItem(this._item,this._amount);
        this.itemList.redrawCurrentItem();
        this.freeSlot.refresh();
        if($gameParty.numItems(this._item) === 0){
            SoundManager.playOk();
            this.itemList.activate();
            this.itemList.refresh();
            this.itemList.updateHelp();
            this.commandWindow.close();
            this.commandWindow.deactivate();
            this.close();
        }else{
            this.closeWindow();
        }
    }
    
    Theo.LINV.Window_Discard.prototype.closeWindow = function(){
        this.close();
        this.commandWindow.activate();
        SoundManager.playOk();
    }
    //===================================================================
    // ** Default Script - Window_ItemList
    //===================================================================
    Window_ItemList.prototype.itemSizeWindow = function(w){
        this._itemSizeWindow = w;
        this._itemSizeWindow.setItem(this.item);
    }
    
    Theo.LINV.itemList_updateHelp = Window_ItemList.prototype.updateHelp;
    Window_ItemList.prototype.updateHelp = function(){
        Theo.LINV.itemList_updateHelp.call(this);
        if (!this._itemSizeWindow){return};
        this._itemSizeWindow.setItem(this.item());
    }
    
    Window_ItemList.prototype.changeHeight = function(height){
        this.height = height;
        this.refresh();
    }
    
    // Overwrite
    Window_ItemList.prototype.isEnabled = function(item) {
          if (item){return true}else{return false};
    };
    //===================================================================
    // ** Default Script - Window_ShopNumber
    //===================================================================
    Theo.LINV.shopNumInit = Window_ShopNumber.prototype.initialize;
    Window_ShopNumber.prototype.initialize = function(x,y,height){
        //Window_ShopNumber.prototype.initialize.call(this, x, y, height);
        Theo.LINV.shopNumInit.call(this, x, y, height);
        this._number = 0;
        this._mode = 'buy';
    }
    
    Theo.LINV.shopNumRefresh = Window_ShopNumber.prototype.refresh;
    Window_ShopNumber.prototype.refresh = function(){
        Theo.LINV.shopNumRefresh.call(this);
        this.drawItemSize();
    }
    
    Window_ShopNumber.prototype.lineHeight = function() {
        return Window_Base.prototype.lineHeight.call(this)
    };
    
    Window_ShopNumber.prototype.drawItemSize = function(){
        let num = this._number * $dataItems[this._item.id].invSize;
        let total = $gameParty.totalInvSize() + (this._mode === 'buy' ? num : num * -1);
        let txt = String(total)+"/"+String($gameParty.invMax());
        let ypos = this.itemY() + this.lineHeight() * 4;
        this.changeTextColor(this.systemColor());
        this.drawText(Theo.LINV.Params['invSlotVocab'],6,ypos,this.contents.width-12);
        this.changeTextColor(this.normalColor());
        this.drawText(txt,6,ypos,this.contents.width-12,'right');
    }
    
    //===================================================================
    // ** Default Script - Window_ShopStatus
    //===================================================================
    if (Theo.LINV.Params['displayItem'] === 'true'){
        Theo.LINV.shopStatusPossession = Window_ShopStatus.prototype.drawPossession;
        Window_ShopStatus.prototype.drawPossession = function(x, y){
            Theo.LINV.shopStatusPossession.call(this, x, y);
            y += this.lineHeight();
            this.drawItemSize(this._item, x, y, this.contents.width - (x*2));
        }
    }
    //===================================================================
    // ** Default Script - Scene_Menu
    //===================================================================
    Theo.LINV.sceneMenuCreate = Scene_Menu.prototype.create;
    Scene_Menu.prototype.create = function(){
        Theo.LINV.sceneMenuCreate.call(this);
        this.createLinvWindow();
    }
    
    Scene_Menu.prototype.createLinvWindow = function(){
        this._linvWindow = new Theo.LINV.Window_MainMenu(this._goldWindow.width);
        this._linvWindow.x = this._commandWindow.x;
        this._linvWindow.y = this._commandWindow.height;
        this._linvWindow.refresh();
        this.addWindow(this._linvWindow);
    }
    //===================================================================
    // ** Default Script - Scene_Item
    //===================================================================
    Theo.LINV.sceneItemCreate = Scene_Item.prototype.create;
    Scene_Item.prototype.create = function(){
        Theo.LINV.sceneItemCreate.call(this);
        this.resizeItemWindow();
        this.createUpperLayer();
        this.createFreeslotWindow();
        this.createItemsizeWindow();
        this.createUsecommandWindow();
        this.createDiscardAmount();
        this.reoderChilds();
    }
    
    Scene_Item.prototype.resizeItemWindow = function(){
        this._itemWindow.height -= this._itemWindow.lineHeight() * 2;
    }
    
    Scene_Item.prototype.reoderChilds = function(){
        this._windowLayer.children.findIndex(function(element){
            if (element === this._actorWindow){
                this._windowLayer.removeChild(element);
                this._windowLayer.addChild(element);
                return true;
            }
            return false;
        },this);
    }
    
    Scene_Item.prototype.createUpperLayer = function(){
        let width = Graphics.boxWidth;
        let height = Graphics.boxHeight;
        let x = (Graphics.width - width) / 2;
        let y = (Graphics.height - height) / 2;
        this._useLayer = new WindowLayer();
        this._useLayer.move(x, y, width, height);
        this.addChild(this._useLayer);
    }
    
    Scene_Item.prototype.addUpperWindow = function(w){
        this._useLayer.addChild(w);
    }
    
    Scene_Item.prototype.createFreeslotWindow = function(){
        let wy = this._itemWindow.y + this._itemWindow.height;
        let wh = Theo.LINV.Params['displayItem'] === 'true' ? Graphics.width/2 : Graphics.width;
        this._freeSlot = new Theo.LINV.Window_FreeSlot(0,wy,wh);
        this.addWindow(this._freeSlot);
    }
    
    Scene_Item.prototype.createItemsizeWindow = function(){
        if(Theo.LINV.Params['displayItem'] === 'false'){return};
        let wx = this._freeSlot.width
        let wy = this._freeSlot.y
        let ww = wx
        this._itemSize = new Theo.LINV.Window_ItemSize(wx,wy,ww)
        this._itemWindow._itemSizeWindow = this._itemSize
        this.addWindow(this._itemSize)
    }
    
    Scene_Item.prototype.createUsecommandWindow = function(){
        this._useCommand = new Theo.LINV.Window_ItemUse()
        this._useCommand.toCenter()
        this._useCommand.setHandler('use', this.useCommandOk.bind(this))
        this._useCommand.setHandler('discard', this.onDiscardOk.bind(this))
        this._useCommand.setHandler('cancel', this.onUseCancel.bind(this))
        this.addUpperWindow(this._useCommand)
    }
    
    Scene_Item.prototype.createDiscardAmount = function(){
        let wx = this._useCommand.x
        let wy = this._useCommand.y + this._useCommand.height
        let ww = this._useCommand.width
        this._discardWindow = new Theo.LINV.Window_Discard(wx,wy,ww)
        this._discardWindow.commandWindow = this._useCommand
        this._discardWindow.itemList = this._itemWindow
        this._discardWindow.freeSlot = this._freeSlot
        this.addUpperWindow(this._discardWindow)
    }
    
    // Overwrite
    Theo.LINV.sceneItem_OnItemOk = Scene_Item.prototype.onItemOk;
    Scene_Item.prototype.onItemOk = function(){
        this._useCommand.setItem(this.item())
        this._useCommand.open()
        this._useCommand.activate()
        this._useCommand.select(0)
    }
    
    Theo.LINV.sceneItem_UseItem = Scene_Item.prototype.useItem;
    Scene_Item.prototype.useItem = function(){
        this._useCommand.close()
        Theo.LINV.sceneItem_UseItem.call(this)
        this._freeSlot.refresh();
    }
    
    Scene_Item.prototype.useCommandOk = function(){
        Theo.LINV.sceneItem_OnItemOk.call(this);
        this._useCommand.close();
    }
    
    Scene_Item.prototype.onDiscardOk = function(){
        this._discardWindow.setItem(this.item())
        this._discardWindow.open()
    }
    
    Scene_Item.prototype.onUseCancel = function(){
        this._itemWindow.activate()
        this._useCommand.close()
        this._useCommand.deactivate()
    }
    
    //===================================================================
    //** Default Script - Scene_Shop
    //===================================================================
    Theo.LINV.shopBuyOk = Scene_Shop.prototype.onBuyOk;
    Scene_Shop.prototype.onBuyOk = function() {
        this._numberWindow._mode = 'buy';
        Theo.LINV.shopBuyOk.call(this);
    };
    
    Theo.LINV.shopSellOk = Scene_Shop.prototype.onSellOk;
    Scene_Shop.prototype.onSellOk = function() {
        this._numberWindow._mode = 'sell';
        Theo.LINV.shopSellOk.call(this);
    };

    Thank you very much, thank you friend, this not only solved the problem of the store, but also solved the problem of the NaN error, it happened to me that when an actor died the load capacity decreased and it gave the NaN error, with this it is already solved, great n.n