Version 1.0
Author AlphaWhelp
Release Date 4/11/11
IntroductionThis script adds a simplistic yet effective item storage/banking scene to your game
FeaturesThe main feature in this script that sets it apart from other item storage scripts is that it uses variables to keep track of which items are stored. Why use a cumbersome system of variables to record this? Well, it gives you, the developer, extremely easy access to the party's stored items at any time, without needing any scripting knowledge whatsoever, simply by checking variables, and the entire storage system can be managed entirely with events without you ever having to write a single line of scripting beyond the one line needed to call the storage scene. You can easily add or subtract items from storage, or you can total some or all of the player's storage inventory entirely with events, though a little scripting knowledge makes larger operations easy.
Also, no offense to other scripters out there, but every other storage script I found on the internet crashed immediately, this script on the other hand is pretty darn stable.
ScriptCODE
module AW
# The following 3 constants determine what variable the items, weapons, and
# armor start recording quantities. Change if you feel comfortable doing so
# just make sure to avoid overlapping variables.
ITEMBEGINNING = 1001
WEAPONBEGINNING = 2001
ARMORBEGINNING = 3001
# The following 3 constants determine how many variables to reserve for items,
# weapons, and armor. if you have items located outside a beginning and
# beginning + limit range, they will not be able to be stored.
ITEMLIMIT = 999
WEAPONLIMIT = 999
ARMORLIMIT = 999
# This constant determines the max number of items holdable in storage.
# Make this as high or low as you want within reason. Variables are not
# unlimited, and if you set this to be too large I can guarantee your
# game will crash.
MAXQUANTITY = 999
# Assuming you leave everything above untouched, variables 1001-1999 will
# be used for storing items, variables 2001 - 2999 for weapons, variables
# 3001 - 3999 for armors. Make sure you have 4000 variables available.
end
CODE
# Do not edit
class Window_Storage_Help < Window_Base
def initialize
super(0, 0, 544, WLH + 32)
end
def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
@text = text
@align = align
end
end
end
CODE
# Do not edit
class Window_Storage_Hud < Window_Base
def initialize
super(0, WLH + 32, 544, WLH + 32)
set_text("Personal Inventory Storage Inventory")
end
def set_text(text, align = 1)
self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
end
end
CODE
# Do not edit
class Window_Storage_Command < Window_Selectable
def initialize(width, commands, column_max = 3, row_max = 1, spacing = 32)
super(0, WLH + 32, width, WLH + 32)
@commands = commands
@item_max = commands.size
@column_max = column_max
refresh
self.index = 0
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, @commands[index])
end
end
CODE
# Do not edit
class Window_Partys_Inventory < Window_Selectable
def initialize(x = 0, y = 112, width = 272, height = 306)
super(x, y, width, height)
@column_max = 1
self.index = 0
refresh
end
# Obtain information on which type of item we will meddle with
def set(type)
@type = type
end
def item
return @data[self.index]
end
def include?(item)
return false if item == nil
case @type
when 0
return false unless item.is_a?(RPG::Item)
when 1
return false unless item.is_a?(RPG::Weapon)
when 2
return false unless item.is_a?(RPG::Armor)
end
return true
end
def refresh
@data = []
for item in $game_party.items
@data.push(item) if include?(item)
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
def enable?(item)
case @type
when 0
return ($game_variables[item.id + AW::ITEMBEGINNING - 1] < AW::MAXQUANTITY)
when 1
return ($game_variables[item.id + AW::WEAPONBEGINNING - 1] < AW::MAXQUANTITY)
when 2
return ($game_variables[item.id + AW::ARMORBEGINNING - 1] < AW::MAXQUANTITY)
end
end
end
CODE
# Do not edit, but see notes below
class Window_Storage_Inventory < Window_Selectable
def initialize(x = 272, y = 112, width = 272, height = 306)
super(x, y, width, height)
@column_max = 1
self.index = 0
refresh
end
# Obtain information on which type of item we will meddle with
def set(type)
@type = type
end
def item
return @data[self.index]
end
def include?(item)
return false if item == nil
case @type
when 0
return false unless item.is_a?(RPG::Item)
when 1
return false unless item.is_a?(RPG::Weapon)
when 2
return false unless item.is_a?(RPG::Armor)
end
return true
end
def refresh
@data = []
case @type
when 0
for storageitems in 1...(AW::ITEMLIMIT + 1)
next unless $game_variables[storageitems + AW::ITEMBEGINNING - 1] > 0
@data.push($data_items[storageitems])
end
when 1
for storageitems in 1...(AW::WEAPONLIMIT + 1)
next unless $game_variables[storageitems + AW::WEAPONBEGINNING - 1] > 0
@data.push($data_weapons[storageitems])
end
when 2
for storageitems in 1...(AW::ARMORLIMIT + 1)
next unless $game_variables[storageitems + AW::ARMORBEGINNING - 1] > 0
@data.push($data_armors[storageitems])
end
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
case @type
when 0
number = $game_variables[item.id + AW::ITEMBEGINNING - 1]
when 1
number = $game_variables[item.id + AW::WEAPONBEGINNING - 1]
when 2
number = $game_variables[item.id + AW::ARMORBEGINNING - 1]
end
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
# If using a script which changes the default item limit away from 99,
# edit this 99 below to the new item limit.
def enable?(item)
return ($game_party.item_number(item) < 99)
end
end
CODE
# Do not edit
class Window_Storage_Number < Window_Base
def initialize(x = 0, y = WLH + 32)
super(x, y, 544, WLH + 32)
@item = nil
@max = 1
@price = 0
@number = 1
end
def set(item, max)
@item = item
@max = max
@number = 1
refresh
end
def number
return @number
end
def refresh
y = 0
self.contents.clear
draw_item_name(@item, 0, y)
self.contents.font.color = normal_color
self.contents.draw_text(212, y, 20, WLH, "×")
self.contents.draw_text(248, y, 20, WLH, @number, 2)
self.cursor_rect.set(244, y, 28, WLH)
end
def update
super
if self.active
last_number = @number
if Input.repeat?(Input::RIGHT) and @number < @max
@number += 1
end
if Input.repeat?(Input::LEFT) and @number > 1
@number -= 1
end
if Input.repeat?(Input::UP) and @number < @max
@number = [@number + 10, @max].min
end
if Input.repeat?(Input::DOWN) and @number > 1
@number = [@number - 10, 1].max
end
if @number != last_number
Sound.play_cursor
refresh
end
end
end
end
CODE
# Do not edit, but see notes below
class Scene_Storage < Scene_Base
def start
super
create_menu_background
@help_window = Window_Storage_Help.new
@hud_window = Window_Storage_Hud.new
@hud_window.visible = false
@main_item_window = Window_Partys_Inventory.new
@main_item_window.active = false
@main_item_window.visible = false
@main_item_window.help_window = @help_window
@item_storage_window = Window_Storage_Inventory.new
@item_storage_window.active = false
@item_storage_window.visible = false
@item_storage_window.help_window = @help_window
@number_window = Window_Storage_Number.new
@number_window.active = false
@number_window.visible = false
@commandindex = 0
@sitems = "Items"
@sweapons = "Weapons"
@sarmors = "Armors"
@command_window = Window_Storage_Command.new(544, [@sitems, @sweapons, @sarmors])
@dummy1 = Window_Base.new(0, 112, 272, 306)
@dummy2 = Window_Base.new(272, 112, 272, 306)
@dummy1.visible = true
@dummy2.visible = true
@command_window.visible = true
@command_window.active = true
end
def terminate
super
dispose_menu_background
@help_window.dispose
@hud_window.dispose
@main_item_window.dispose
@item_storage_window.dispose
@number_window.dispose
@command_window.dispose
@dummy1.dispose
@dummy2.dispose
end
def update
super
update_menu_background
@help_window.update
@main_item_window.update
@item_storage_window.update
@command_window.update
@number_window.update
if @command_window.active
update_command_selection
elsif @main_item_window.active
update_main_item_selection
elsif @item_storage_window.active
update_item_store_selection
elsif @number_window.active
update_number_input
end
end
def update_command_selection
if Input.trigger?(Input::

Sound.play_cancel
$scene = Scene_Map.new
end
if Input.trigger?(Input::C)
Sound.play_decision
@indextype = @command_window.index
@command_window.active = false
@command_window.visible = false
@hud_window.visible = true
@main_item_window.set(@indextype)
@main_item_window.visible = true
@main_item_window.active = true
@main_item_window.refresh
@item_storage_window.set(@indextype)
@item_storage_window.visible = true
@item_storage_window.refresh
@dummy1.visible = false
@dummy2.visible = false
@commandindex = 0
end
end
def update_main_item_selection
if Input.trigger?(Input::

Sound.play_cancel
@dummy1.visible = true
@dummy2.visible = true
@hud_window.visible = false
@main_item_window.visible = false
@main_item_window.active = false
@item_storage_window.visible = false
@command_window.visible = true
@command_window.active = true
end
if Input.trigger?(Input::RIGHT)
Sound.play_cursor
@main_item_window.active = false
@item_storage_window.active = true
@commandindex = 1
end
if Input.trigger?(Input::C)
@item = @main_item_window.item
number = $game_party.item_number(@item)
case @indextype
when 0
beginning = AW::ITEMBEGINNING
when 1
beginning = AW::WEAPONBEGINNING
when 2
beginning = AW::ARMORBEGINNING
end
if @item == nil or $game_variables[@item.id + beginning - 1] == AW::MAXQUANTITY
Sound.play_buzzer
else
Sound.play_decision
max = [AW::MAXQUANTITY - $game_variables[@item.id + beginning - 1], $game_party.item_number(@item)].min
@main_item_window.active = false
@number_window.set(@item, max)
@number_window.active = true
@number_window.visible = true
@hud_window.visible = false
end
end
end
def update_item_store_selection
if Input.trigger?(Input::

Sound.play_cancel
@dummy1.visible = true
@dummy2.visible = true
@hud_window.visible = false
@main_item_window.visible = false
@item_storage_window.active = false
@item_storage_window.visible = false
@command_window.visible = true
@command_window.active = true
end
if Input.trigger?(Input::LEFT)
Sound.play_cursor
@item_storage_window.active = false
@main_item_window.active = true
@commandindex = 0
end
if Input.trigger?(Input::C)
case @indextype
when 0
beginning = AW::ITEMBEGINNING
when 1
beginning = AW::WEAPONBEGINNING
when 2
beginning = AW::ARMORBEGINNING
end
@item = @item_storage_window.item
number = $game_variables[@item.id + beginning - 1]
# If using a script which changes the default item limit away from 99,
# edit this 99 below to the new item limit.
if @item == nil or $game_party.item_number(@item) == 99
Sound.play_buzzer
else
Sound.play_decision
# If using a script which changes the default item limit away from 99,
# edit this 99 below to the new item limit.
max = [number, 99 - $game_party.item_number(@item)].min
@item_storage_window.active = false
@number_window.set(@item, max)
@number_window.active = true
@number_window.visible = true
@hud_window.visible = false
end
end
end
def update_number_input
if Input.trigger?(Input::

cancel_number_input
elsif Input.trigger?(Input::C)
decide_number_input
end
end
def cancel_number_input
Sound.play_cancel
@number_window.active = false
@number_window.visible = false
@hud_window.visible = true
case @commandindex
when 0 # Store
@main_item_window.active = true
when 1 # Take
@item_storage_window.active = true
end
end
def decide_number_input
Sound.play_shop
@number_window.active = false
@number_window.visible = false
@hud_window.visible = true
case @indextype
when 0
beginning = AW::ITEMBEGINNING
when 1
beginning = AW::WEAPONBEGINNING
when 2
beginning = AW::ARMORBEGINNING
end
case @commandindex
when 0 # Store
$game_party.lose_item(@item, @number_window.number)
$game_variables[@item.id + beginning - 1] += @number_window.number
@main_item_window.active = true
when 1 # Take
$game_party.gain_item(@item, @number_window.number)
$game_variables[@item.id + beginning - 1] -= @number_window.number
@item_storage_window.active = true
end
@main_item_window.refresh
@item_storage_window.refresh
end
end
CustomizationAll customization options are located within module AW.
CompatibilityYou will have issues with scripts which change the default limit per item your party is allowed to carry away from 99. If you're using a different item limit, whether it is lower or higher, you must examine Window_Storage_Inventory and Scene_Storage and change 99 values to the new item limit.
Screenshot
Uploaded with
ImageShack.usDEMOhttp://www.mediafire.com/?i7otfbtgioysg5fInstallationplug-n-play, I highly recommend copying the scripts out of the demo instead of from this message board. paste under Materials but before Main. You must have enough variables for the script to use or else it won't work.
FAQThis script is provided as is... no further changes will be made to the script by me unless it's a bugfix to the function intended by the original script. If you are a scripter, however, feel free to change it on your own all you want, but don't ask me for help if you break it.
Terms and ConditionsCredit me if you use this script, it may just be a spaghetti code mess of default scripts, but it took real effort. Commercial projects don't need special approval from me.
CreditsJust AlphaWhelp.
This post has been edited by AlphaWhelp: Apr 12 2011, 05:48 AM