Help - Search - Members - Calendar
Full Version: Item Quantity
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS
drei7717
Wear in the script database I can change the amount of items i can hold? for example
the amount of different type of items you can hold is 10 but the amount of that one item you can hold is 6
Redd
Moving to RGSS Script Support, since this has to do with scripts.
Night_Runner
Something like this?

Night_Runner's Item Limiting Script
CODE
#==============================================================================
# ** Night_Runner's Item Limiting Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 28/Jun/11
#  Created for: drei7717
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=51186
#
# Description:
#  This script is designed to limit the maximum number of an individual item,
#   and the number of different items available in the party
#
# How to Install:
#  Copy this entire script. In your game, along the top select Tools >>
#   Script Editor. Along the left, scroll all the way down to the bottom,
#   right click on 'Main', and select 'Insert'. Paste this code in the
#   blank window on the right.
#
# Customization:
#  Line 49 defines the maximum number of an individual item can be held
#   (by default, 10).
#  Line 58 defines the maximum number of different items can be held
#   (by default, 6).
#==============================================================================



#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  Edited to limit the number of items available, and the number of different
#  items available
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_itemLimiter_gain_item  gain_item  unless $@
  #--------------------------------------------------------------------------
  # * Gain Items (or lose)
  #     item_id : item ID
  #     n       : quantity
  #--------------------------------------------------------------------------
  def gain_item(item_id, n)
    # Limit the gain to there can only be a maximum of 10 of this item in
    #  the party
    n = [ 10 - item_number(item_id), n ].min
    # Get a variable to store the number of items
    num_different_items = 0
    # Loop through every item
    for id in 1...$data_items.size
      # Increment the number of different items if this item is in the party
      num_different_items += 1 if item_number(id) > 0
    end
    # If there are less than 6 different items in the party
    if num_different_items < 6
      # Run the original gain_item
      nr_itemLimiter_gain_item(item_id, n)
    end
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.