Notice: fwrite(): Write of 461 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 59 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 1714 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 8192 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96
Print Page - Inventory Limits

The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: Synthesize on August 15, 2007, 09:25:56 PM

Title: Inventory Limits
Post by: Synthesize on August 15, 2007, 09:25:56 PM
Script Name:  Inventory Limitations
Written by: Synthesize
Current Version: V.1.00
Release Date: August 13, 2007

What is it?
Inventory Limitations is a simple script that aliases some Game_Party methods allowing the party to carry only a certain amount of items at a single time. In order to carry more items at one time the 'bag' must be upgraded, this is done by storing the Bag sizes into an Array and then calling the flag. As an example, if you use the default value size of 50 items, then you can carry 25 potions and say 25 high potions. Afterwards your inventory is full since 25+25 = 50. Oh and I indented it better then others, cookie please.

Future Plans:
I plan on expanding the script once I get some more time, things I am planning include:
- Create Windows & a Scene
- Add more Designer customization
- Add more features

Screenshots
I did not make any Window's or Scenes yet so that might be kind of tough at the moment...So instead of looking at screen shots, go eat some pizza.

DEMO
http://www.megaupload.com/?d=YDMGAFTI (http://www.megaupload.com/?d=YDMGAFTI)
Demo Script Version: 1.00

The Script

[spoiler]

#============================================================================
# *Syn's Item Limits*
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 1.00
# August 13, 2007
# Tested with SDK 2.1
#============================================================================
=begin
-=What is it?=-
  The purpose of this script is to allow Item Limitation, or in other words
limit the number of items the party can carry at one time. By default,
the party can carry 99 of every single item in the database. With this script
the party can only carry 50 items (Default value) and every item in the database
affects this number. As an example, say you have 25 potions and 25 High Potions,
now your inventory is full and the party cannot collect more items. That is, unless
you go out and buy a bigger bag.
Bag sizes are stored in an Array and called on by a flag. So virtually,
you can have as many items as you want, but you need a bigger bag to accomplish that.

-=Future Additions=-
- Make Custom Item Scene which displays Total Space and etc
- Most likely add more features

=end
#----------------------------------------------------------------------------
# Compatiability
#----------------------------------------------------------------------------
# Tested with SDK 2.1
# Tested with DerVVulfman's Grouping and Details
# Aliases the following:
#   Game_Party::gain_item
#   Game_Party::gain_weapon
#   Game_Party::gain_armor
#   Game_Party::initialize
#   Scene_Equip::Main
#---------------------------------------------------------------------------
# Begin Customization Section
#---------------------------------------------------------------------------
module ItemLimits
  # Item Limit Options #
  Max_item_storage = {1 => 75, 2 => 100, 3 => 125}   # Format {flag_id => new_size}
  # This defiens the default value of the amount of items to be stored.
  Max_item_storage.default = 50
end
#---------------------------------------------------------------------------
# End Customization Section
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Begin Game Party Aliased Methods
#---------------------------------------------------------------------------
class Game_Party
  attr_accessor :storage_flag   
  attr_accessor :item_storage 
  attr_accessor :item_count
  #---------------------------------------------------------------------------
  # Aliased Methods
  #   Game_Party::gain_item
  #   Game_Party::gain_weapon
  #   Game_Party::gain_armor
  #   Game_Party::initialize
  #---------------------------------------------------------------------------
  alias syn_gain_item gain_item
  alias syn_gain_weapon gain_weapon
  alias syn_gain_armor gain_armor
  alias syn_init initialize
  #---------------------------------------------------------------------------
  # Initialize
  # Add additional variables
  #---------------------------------------------------------------------------
  def initialize
@item_count = 0
syn_init
  end
  #---------------------------------------------------------------------------
  # Gain_Item
  #   item_id = Target Item ID
  #   n = amount of item_id which is being added
  #---------------------------------------------------------------------------
  def gain_item(item_id,n)
syn_gain_item(item_id,n)
syn_item_limits(item_id, n,0)
  end
  #---------------------------------------------------------------------------
  # Gain_Weapon
  #   item_id = Target Item ID
  #   n = amount of item_id which is being added
  #---------------------------------------------------------------------------
  def gain_weapon(weapon_id,n)
syn_gain_weapon(weapon_id,n)
syn_item_limits(weapon_id, n,1)
  end
  #---------------------------------------------------------------------------
  # Gain_Armor
  #   item_id = Target Item ID
  #   n = amount of item_id which is being added
  #---------------------------------------------------------------------------
  def gain_armor(weapon_id,n)
syn_gain_armor(weapon_id,n)
syn_item_limits(weapon_id, n,2)
  end
  #---------------------------------------------------------------------------
  # Syn Item Limits
  #   item_id = Target Item ID
  #   n = The amount of items to add
  #   value = Type of Item being checked
  #---------------------------------------------------------------------------
  def syn_item_limits(item_id, n, value)
@item_storage = ItemLimits::Max_item_storage[@storage_flag]
item_difference = @item_count + n
leftover = item_difference - @item_storage
case value
# Item
when 0
  if item_difference > @item_storage
@item_count = item_difference
gain_item(item_id,-leftover)
  else
@item_count = item_difference
  end
# Weapon
when 1
  if item_difference > @item_storage
@item_count = item_difference
gain_weapon(item_id,-leftover)
  else
@item_count = item_difference
  end
# Armor
when 2
  if item_difference > @item_storage
@item_count = item_difference
gain_armor(item_id,-leftover)
  else
@item_count = item_difference
  end
end
  end
end
  #---------------------------------------------------------------------------
  # End Game_Party modification
  #--------------------------------------------------------------------------
  # Begin Scene_Equip Alias
  #--------------------------------------------------------------------------
class Scene_Equip
  alias syn_equip_main main
  def main
# Adds dummy pockets. Prevents items from erasing when unequipping.
$game_party.item_storage += 4
syn_equip_main
$game_party.item_storage -= 4
  end
end
#-----------------------------------------------------------------------------
#=============================================================================
# Special Thanks: Northern49 for the General Idea
# Tested with SDK 2.1
# May be incompatible with scripts that modify the mentioned aliased classes
#-----------------------------------------------------------------------------
# *Syn's Item Limits*
#=============================================================================

[/spoiler]

Usage
Usage:
This script may be used in either a commercial project or a free ware project free of charge. However, credit must be present somewhere in the project.

Editing/Distribution:
Feel free to redistribute this post to other boards/websites. Just keep the wording the same. As for editing the script to suite your tastes feel free. Just keep the original header/footer in tact.

If you have any questions or you found a bug, please PM me or make a post with the following:
1.) SDK Version
2.) Other Scripts
3.) Factors of the bug (What did you do to make it happen?)
4.) version
5.) Error Line

Cheers,

Syn
Title: Re: Inventory Limits
Post by: modern algebra on August 15, 2007, 10:12:30 PM
Another nice script. Just as a question, what windows and scenes are you thinking about? I've racked my brain for almost 1 minute and can't think of what it would be,
Title: Re: Inventory Limits
Post by: Synthesize on August 15, 2007, 10:21:21 PM
They would be rewrites of Window_Item and Scene_Item which will make them show some of the features I have planned, such as a weight system.
Title: Re: Inventory Limits
Post by: Beef on June 09, 2008, 03:41:59 AM
I tried using this script and it works but there doesn't seem to be any way to prevent ignoring new items given to you, they just simply disappear, for example: if you go into a store with your item limit and buy something, you spend the money, but your inventory doesn't change at all, and if you are given an item from an event or monster it simply doesn't enter your inventory. If you know of any way to prompt throwing out old items or how to make a trigger or conditional branch that triggers when you have a full inventory please reply.
Title: Re: Inventory Limits
Post by: Mr_Wiggles on December 01, 2009, 09:20:38 AM
Quote from: Synthesize on August 15, 2007, 10:21:21 PM
They would be rewrites of Window_Item and Scene_Item which will make them show some of the features I have planned, such as a weight system.
intresting i have such a request for a script here
http://rmrk.net/index.php/topic,35671.msg428775.html#msg428775
perhaps you can up date me if and when you do so?
Title: Re: Inventory Limits
Post by: Grafikal on December 01, 2009, 06:30:15 PM
I think you need to calm down on your posts in here. I don't really mind since most are decent feedback and I suppose some of these scripts could use a lift, however, if you have questions with the authors or something and it's been over a year since the last post, much less the first post, send them a PM or Email instead. It's possible they're not as active or not active anymore and won't get this post unless they have it set on Email Alerts or something. Just try to avoid useless necroposting, which is where I see this heading.