#sb:item_limit [message]=begin#===============================================================================Napoleons Item LimitVersion 1.01By NapoleonAbout:- Allows you to set a custom limit for all items as well as for specific items (in shops).- Can optionally also set a limit for manually increasing the item limit through events or through script calls.- Supports item notetags.Instructions:- Place below "▼ Materials" but above "▼ Main Process". Requires:- RPG Maker VX AceTerms of Use:- This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
http://creativecommons.org/licenses/by/4.0/deed.en_US.- Attribution is not required. This overrules what's stated in the above license. Version History:1.01 (28 July 2014) - Added an optional item limiter for adding items through other means. - Now supports notetags1.00 (28 July 2014) - First Release=endmodule Nap; module Item_Limit#===============================================================================# Settings#=============================================================================== # This is the default allowed maximum quantity. # This value is used when an item is not listed in SPECIFIC_ITEM_LIMITS. # Does not exceed 99 unless LIMIT_GLOBALLY is set to true. MAX_ITEMS = 99 # Set specific maximum item quantities here (note-tags overrule these). SPECIFIC_ITEM_LIMITS = { # <item_id> => <max quantity>, 9 => 5, # max 5x "Life Up" } # Limits items gained through chests and events as well when set to true. LIMIT_GLOBALLY = true # REGEX notetag. Only change if you know what you are doing. NOTE_TAG_REGEX = /<item_limit

\d*)>/i#===============================================================================# Do not edit below this line#=============================================================================== SPECIFIC_ITEM_LIMITS.default = MAX_ITEMS def self.max_items(item_id) return SPECIFIC_ITEM_LIMITS[item_id] endend; end # module Nap; module Item_Limit$imported ||= {}$imported[:nap_item_limit] = 1.01#===============================================================================# Window ShopBuy#===============================================================================class Window_ShopBuy < Window_Selectable #----------------------------------------------------------------------------- # enable? [ALIAS] #----------------------------------------------------------------------------- alias nap_shop_item_limit_enable? enable? def enable?(item) nap_shop_item_limit_enable?(item) && $game_party.item_number(item) < Nap::Item_Limit.max_items(item.id) endend#===============================================================================# Scene Shop#===============================================================================class Scene_Shop < Scene_MenuBase #----------------------------------------------------------------------------- # Max Buy [ALIAS] #----------------------------------------------------------------------------- alias nap_shop_item_limit_max_buy max_buy def max_buy max_with_limit = Nap::Item_Limit.max_items(@item.id) - $game_party.item_number(@item) return [nap_shop_item_limit_max_buy, max_with_limit].min endend#===============================================================================# Game Party#===============================================================================if Nap::Item_Limit::LIMIT_GLOBALLY class Game_Party < Game_Unit #--------------------------------------------------------------------------- # Max Item Number [OVERWRITE] #--------------------------------------------------------------------------- def max_item_number(item) return Nap::Item_Limit.max_items(item.id) end endend#===============================================================================# Data Manager#===============================================================================module DataManager class << self alias nap_shop_item_limit_load_database load_database end #----------------------------------------------------------------------------- # Load Database [ALIAS] #----------------------------------------------------------------------------- def self.load_database nap_shop_item_limit_load_database $data_items.each { |item| next if item.nil? Nap::Item_Limit::SPECIFIC_ITEM_LIMITS[item.id] = $1.to_i if item.note.delete(' ') =~ Nap::Item_Limit::NOTE_TAG_REGEX } endend#===============================================================================