I found this script on the web earlier but don't know how to use it. Can anyone help?
# Keep_Items
#
#
module Keep_Items_Module
class Keep_Items
class Keep_Item
def initialize(name)
@name = name
@items = {}
@weapons = {}
@armors = {}
@gold = 0
end
def add_item(item)
@items[item.id] = [] if @items[item.id].nil?
@items[item.id].push item
end
def add_weapon(item)
@weapons[item.id] = [] if @weapons[item.id].nil?
@weapons[item.id].push item
end
def add_armor(item)
@armors[item.id] = [] if @armors[item.id].nil?
@armors[item.id].push item
end
def add(item)
case item
when RPG::Item
add_item item
when RPG::Weapon
add_weapon item
when RPG::Armor
add_armor item
end
end
def remove_item(item)
return if @items[item.id].nil?
@items[item.id].pop
end
def remove_weapon(item)
return if @weapons[item.id].nil?
@weapons[item.id].pop
end
def remove_armor(item)
return if @armors[item.id].nil?
@armors[item.id].pop
end
def remove(item)
case item
when RPG::Item
remove_item item
when RPG::Weapon
remove_weapon item
when RPG::Armor
remove_armor item
end
end
def item_number(id)
return @items[id].nil? ? 0 : @items[id].size
end
def weapon_number(id)
return @weapons[id].nil? ? 0 : @weapons[id].size
end
def armor_number(id)
return @armors[id].nil? ? 0 : @armors[id].size
end
def gold
return @gold
end
def gain_item(id,num)
(0...num).each {add_item $data_items[id]}
end
def gain_weapon(id,num)
(0...num).each {add_weapon $data_weapons[id]}
end
def gain_armor(id,num)
(0...num).each {add_armor $data_armors[id]}
end
def gain_gold(gold)
@gold += gold
end
def lose_item(id,num)
(0...num).each {remove_item $data_items[id]}
end
def lose_weapon(id,num)
(0...num).each {remove_weapon $data_weapons[id]}
end
def lose_armor(id,num)
(0...num).each {remove_armor $data_armors[id]}
end
def lose_gold(gold)
@gold -= gold
end
end
def initialize
@keep_items = {}
end
def [](name)
if @keep_items[name].nil?
@keep_items[name] = Keep_Item.new name
end
return @keep_items[name]
end
end
module Game_Party
def keep_items
if @keep_items.nil?
@keep_items = Keep_Items.new
end
return @keep_items
end
def swap_keep_item(name1,name2)
Keep_Items_Module.swap_keep_item(self,self.keep_items[name1])
Keep_Items_Module.swap_keep_item(self.keep_items[name2],self)
end
end
def swap_keep_item(keep_item_a,keep_item_b)
# アイテムを追åŠ
for i in 1...$data_items.size
num = keep_item_a.item_number(i)
if num > 0
keep_item_b.gain_item(i,num)
keep_item_a.lose_item(i,num)
end
end
for i in 1...$data_weapons.size
num = keep_item_a.weapon_number(i)
if num > 0
keep_item_b.gain_weapon(i,num)
keep_item_a.lose_weapon(i,num)
end
end
for i in 1...$data_armors.size
num = keep_item_a.armor_number(i)
if num > 0
keep_item_b.gain_armor(i,num)
keep_item_a.lose_armor(i,num)
end
end
gold = keep_item_a.gold
keep_item_b.gain_gold(gold)
keep_item_a.lose_gold(gold)
end
module_function :swap_keep_item
end # module Keep_Items_Module
class Game_Party
include Keep_Items_Module::Game_Party
end
# Keep_Items
# Scene_Framework
#
#
#
if true
#==============================================================================
# ■シーンフレームワーク
#==============================================================================
module Scene_Framework
module Window_Menu
NAME = 'name'
HELP = 'help'
PROC = 'proc'
def add_menu(name,menu_item)
@menu_list = [] if @menu_list.nil?
menu_item[NAME] = name
@menu_list.push menu_item
end
def menu_names
names = []
@menu_list.each {|menu| names.push menu[NAME]}
return names
end
def menu_call(index)
@menu_list[index][PROC].call if not @menu_list[index][PROC].nil?
end
def menu_help(index)
return @menu_list[index][HELP].nil? ? '' : @menu_list[index][HELP]
end
def input_c
menu_call(@index)
end
def start_active_window
self.index = 0
end
def help_text
return menu_help(@index)
end
def update_help
@help_window.set_text help_text
end
end
module Window_Module
def buzzer_se
# ブザー SE ã‚’æ¼”å¥
$game_system.se_play($data_system.buzzer_se)
end
def decision_se
# 決定 SE ã‚’æ¼”å¥
$game_system.se_play($data_system.decision_se)
end
def cancel_se
# ã‚ャンセル SE ã‚’æ¼”å¥
$game_system.se_play($data_system.cancel_se)
end
def cursor_se
# カーソル SE ã‚’æ¼”å¥
$game_system.se_play($data_system.cursor_se)
end
def shop_se
# ショップ SE ã‚’æ¼”å¥
$game_system.se_play($data_system.shop_se)
end
def center
self.x = 640 / 2 - self.width / 2
self.y = 480 / 2 - self.height / 2
end
def cancel?
# B ボタンãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
if Input.trigger?(Input::B)
cancel_se
return true
end
return false
end
def select?
# C ボタンãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
return Input.trigger?(Input::C)
end
attr_reader :input_hander
def setup_default_input_hander
return if not @input_hander.nil?
@input_hander = {}
handers = {
Input::A => 'input_a',
Input::B => 'input_b',
Input::C => 'input_c',
Input::X => 'input_x',
Input::Y => 'input_y',
Input::Z => 'input_z',
Input::LEFT => 'input_left',
Input::RIGHT => 'input_right',
Input::UP => 'input_up',
Input::DOWN => 'input_down',
}
handers.each do |code,method_name|
if not self.methods.index(method_name).nil?
@input_hander[code] = self.method(method_name)
end
end
end
def input_b
cancel_se
$scene.back_window
end
def update_active_window
if @input_hander.nil?
setup_default_input_hander
end
input_hander.each do |code,method_name|
if Input.repeat?(code)
method_name.call
end
end
end
end
class Window_YesNo < Window_Command
include Scene_Framework::Window_Module
attr_accessor :select_proc
attr_accessor :cancel_proc
def initialize
super(100,['Select','Cancel'])
@select_proc = nil
@cancel_proc = nil
center
end
def yes?
return @index == 0
end
def no?
return @index == 1
end
def update_active_window
if cancel?
@cancel_proc.call if not cancel_proc.nil?
$scene.back_window
return
end
if select? and no?
@cancel_proc.call if not cancel_proc.nil?
cancel_se
$scene.back_window
return
end
if select? and yes?
@select_proc.call if not @select_proc.nil?
return
end
end
end
attr_reader :windows
#--------------------------------------------------------------------------
# åˆæœŸåŒ–
#--------------------------------------------------------------------------
def initialize
@windows = {}
@active_windows = []
@visible_windows = []
end
#--------------------------------------------------------------------------
# ウィンドウã®è¿½åŠ
#--------------------------------------------------------------------------
def add_window(name, window, visible = false)
@windows[name] = window
if visible
@visible_windows.push window
end
update_visibility
return window
end
#--------------------------------------------------------------------------
# 次ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦
#--------------------------------------------------------------------------
def next_window(name)
active_window = windows[name]
@active_windows.push active_window
update_activity_window_z
if not active_window.methods.index('start_active_window').nil?
active_window.start_active_window
end
update_visibility
update_activity
end
#--------------------------------------------------------------------------
# 戻る
#--------------------------------------------------------------------------
def back_window
active_window = @active_windows[@active_windows.size - 1]
if not active_window.methods.index('end_active_window').nil?
active_window.end_active_window
end
@active_windows.pop
update_visibility
update_activity
end
#--------------------------------------------------------------------------
# 表示固定ウィンドウã®è¨å®š
#--------------------------------------------------------------------------
def set_visible_window(name,visible=true)
if visible
if @visible_windows.index(windows[name]).nil?
@visible_windows.push windows[name]
end
else
@visible_windows.delete windows[name]
end
update_visibility
end
#--------------------------------------------------------------------------
# z index æ›´æ–°
#--------------------------------------------------------------------------
def update_activity_window_z
z = 100
@active_windows.each do |window|
window.z = z
z += 10
end
end
#--------------------------------------------------------------------------
# 表示状態更新
#--------------------------------------------------------------------------
def update_visibility
windows.each_value do |window|
window.visible = false
end
@visible_windows.each do |window|
window.visible = true
end
@active_windows.each do |window|
window.visible = true
end
end
#--------------------------------------------------------------------------
# アクティブ状態更新
#--------------------------------------------------------------------------
def update_activity
windows.each_value do |window|
window.active = false
end
active_window = @active_windows[@active_windows.size - 1]
active_window.active = true if not active_window.nil?
end
#--------------------------------------------------------------------------
# メインåˆæœŸå‡¦ç†
#--------------------------------------------------------------------------
def main_start
end
#--------------------------------------------------------------------------
# メイン後処ç†
#--------------------------------------------------------------------------
def main_end
windows.each_value do |window|
window.dispose
end
end
#--------------------------------------------------------------------------
# ウィンドウ更新
#--------------------------------------------------------------------------
def update_window
windows.each_value do |window|
window.update if window.visible
end
end
#--------------------------------------------------------------------------
# アクティブウィンドウ処ç†
#--------------------------------------------------------------------------
def update_active_window
if @active_windows.empty?
$scene = Scene_Map.new
return
end
active_window = @active_windows[@active_windows.size - 1]
active_window.update_active_window
end
#--------------------------------------------------------------------------
# メイン処ç†
#--------------------------------------------------------------------------
def main
# メインスタート
main_start
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画é¢ã‚’æ›´æ–°
Graphics.update
# å…¥åŠ›æƒ…å ±ã‚’æ›´æ–°
Input.update
# フレーム更新
update
# ç”»é¢ãŒåˆ‡ã‚Šæ›¿ã‚ã£ãŸã‚‰ãƒ«ãƒ¼ãƒ—ã‚’ä¸æ–
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# メインエンド
main_end
end
#--------------------------------------------------------------------------
# フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
update_window
# アクティブウィンドウ処ç†
update_active_window
end
end
end
# Scene_Framework
# Scene_Keep_Item
#
#
class Scene_Keep_Item
include Scene_Framework
class Main_Menu < Window_Command
include Scene_Framework::Window_Module
def initialize
super(160,['Storage','Remove','Cancel'])
@menu_hander = []
@menu_hander[0] = proc {decision_se; $scene.next_window :Item_Kind_Menu}
@menu_hander[1] = proc {decision_se; $scene.next_window :Item_Kind_Menu}
@menu_hander[2] = proc {cancel_se; $scene.back_window}
center
@help_window = $scene.windows[:Window_Help]
end
def start_active_window
@index = 0
end
def input_c
@menu_hander[@index].call
end
def push?
return @index == 0
end
def pop?
return @index == 1
end
def help_text
return "" if @index == 2
return @commands[@index]
end
def update_help
@help_window.set_text(help_text)
end
end
class Item_Kind_Menu < Window_Command
include Scene_Framework::Window_Module
def initialize
super(160,[
$data_system.words.item,
$data_system.words.weapon,
'Armor',
'Money',
'Cancel'
])
@menu_hander = []
@menu_hander[0] = proc {decision_se; $scene.next_window :Item_Select}
@menu_hander[1] = proc {decision_se; $scene.next_window :Item_Select}
@menu_hander[2] = proc {decision_se; $scene.next_window :Item_Select}
@menu_hander[3] = proc {decision_se; $scene.next_window :Gold_Number}
@menu_hander[4] = proc {cancel_se; $scene.back_window}
center
@help_window = $scene.windows[:Window_Help]
end
def start_active_window
@index = 0
end
def input_c
@menu_hander[@index].call
end
def item?
return @index == 0
end
def weapon?
return @index == 1
end
def armor?
return @index == 2
end
def help_text
return "" if @index == 4
return "#{@commands[@index]}ã‚’#{$scene.windows[:Main_Menu].help_text}"
end
def update_help
@help_window.set_text(help_text)
end
end
#--------------------------------------------------------------------------
# ◠アイテムé¸æŠžã‚¦ã‚£ãƒ³ãƒ‰ã‚¦
#--------------------------------------------------------------------------
class Item_Select < Window_Item
include Scene_Framework::Window_Module
def initialize
super
@keep_item = nil
@help_window = $scene.windows[:Window_Help]
end
def input_c
if not item.nil?
$scene.next_window :Item_Number
end
end
def item_number
return $scene.item_number(@keep_item,item)
end
def start_active_window
@index = 0
if $scene.windows[:Main_Menu].push?
@keep_item = $game_party
end
if $scene.windows[:Main_Menu].pop?
@keep_item = $scene.keep_item
end
refresh
end
#--------------------------------------------------------------------------
# ◠アイテムリフレッシュ
#--------------------------------------------------------------------------
def refresh_items
return if @keep_item.nil?
# アイテムを追åŠ
for i in 1...$data_items.size
if @keep_item.item_number(i) > 0
@data.push($data_items)
end
end
end
#--------------------------------------------------------------------------
# â— æ¦å™¨ãƒªãƒ•ãƒ¬ãƒƒã‚·ãƒ¥
#--------------------------------------------------------------------------
def refresh_weapons
return if @keep_item.nil?
for i in 1...$data_weapons.size
if @keep_item.weapon_number(i) > 0
@data.push($data_weapons)
end
end
end
#--------------------------------------------------------------------------
# ◠防具リフレッシュ
#--------------------------------------------------------------------------
def refresh_armors
return if @keep_item.nil?
for i in 1...$data_armors.size
if @keep_item.armor_number(i) > 0
@data.push($data_armors)
end
end
end
#--------------------------------------------------------------------------
# â— å…¨ã¦ãƒªãƒ•ãƒ¬ãƒƒã‚·ãƒ¥
#--------------------------------------------------------------------------
def refresh_all
refresh_items
refresh_weapons
refresh_armors
end
#--------------------------------------------------------------------------
# ◠コンテンツリフレッシュ
#--------------------------------------------------------------------------
def refresh_contents
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
end
end
#--------------------------------------------------------------------------
# ◠リフレッシュ
#--------------------------------------------------------------------------
def refresh
@data = []
item_kind_menu = $scene.windows[:Item_Kind_Menu]
if item_kind_menu.item?
refresh_items
end
if item_kind_menu.weapon?
refresh_weapons
end
if item_kind_menu.armor?
refresh_armors
end
refresh_contents
draw_all
end
#--------------------------------------------------------------------------
# â— æç”»
#--------------------------------------------------------------------------
def draw_all
# é …ç›®æ•°ãŒ 0 ã§ãªã‘ã‚Œã°ãƒ“ットマップを作æˆã—ã€å…¨é …目をæç”»
if @item_max > 0
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# â— é …ç›®ã®æç”»
# index : é …ç›®ç•ªå·
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = @keep_item.item_number(item.id)
when RPG::Weapon
number = @keep_item.weapon_number(item.id)
when RPG::Armor
number = @keep_item.armor_number(item.id)
end
self.contents.font.color = normal_color
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
end
class Gold_Number < Window_InputNumber
include Scene_Framework::Window_Module
def initialize
super(9)
self.opacity = 255
center
@help_window = $scene.windows[:Window_Help]
end
def help_text
return "#{$scene.windows[:Item_Kind_Menu].help_text}"+
" (#{$scene.pop_keep_item.gold}#{$data_system.words.gold})"
end
def update
super
@help_window.set_text(help_text)
end
def input_c
if $scene.pop_keep_item.gold < number
buzzer_se
return
end
$scene.push_keep_item.gain_gold number
$scene.pop_keep_item.lose_gold number
decision_se
$scene.back_window
end
end
class Item_Number < Window_InputNumber
include Scene_Framework::Window_Module
def initialize
super(2)
self.opacity = 255
center
@help_window = $scene.windows[:Window_Help]
end
def help_text
item_select = $scene.windows[:Item_Select]
item = item_select.item
return "#{item.name} #{item_select.item_number}個"
end
def update
super
@help_window.set_text(help_text)
end
def input_c
item_select = $scene.windows[:Item_Select]
if item_select.item_number < number
buzzer_se
return
end
item = item_select.item
if ($scene.item_number($scene.push_keep_item,item) + number) > 99
buzzer_se
return
end
item_kind_menu = $scene.windows[:Item_Kind_Menu]
if item_kind_menu.item?
kind_name = 'item'
elsif item_kind_menu.weapon?
kind_name = 'weapon'
elsif item_kind_menu.armor?
kind_name = 'armor'
end
$scene.push_keep_item.method("gain_#{kind_name}").call(item.id,number)
$scene.pop_keep_item.method("lose_#{kind_name}").call(item.id,number)
item_select.refresh
decision_se
$scene.back_window
end
end
attr_reader :keep_item
def initialize(name)
super()
@keep_item = $game_party.keep_items[name]
end
def main_start
super
window = add_window(:Window_Help,Window_Help.new,true)
window = add_window(:Main_Menu,Main_Menu.new)
window = add_window(:Item_Kind_Menu,Item_Kind_Menu.new)
window = add_window(:Item_Select,Item_Select.new)
window = add_window(:Gold_Number,Gold_Number.new)
window = add_window(:Item_Number,Item_Number.new)
next_window(:Main_Menu)
end
def push_keep_item
main_menu = $scene.windows[:Main_Menu]
if main_menu.push?
return $scene.keep_item
end
if main_menu.pop?
return $game_party
end
return nil
end
def pop_keep_item
main_menu = $scene.windows[:Main_Menu]
if main_menu.push?
return $game_party
end
if main_menu.pop?
return $scene.keep_item
end
return nil
end
def item_number(keep_item,item)
case item
when RPG::Item
return keep_item.item_number(item.id)
when RPG::Weapon
return keep_item.weapon_number(item.id)
when RPG::Armor
return keep_item.armor_number(item.id)
end
return 0
end
module Event_Script
def check_room(name)
$scene = Scene_Keep_Item.new(name)
end
def check_room_run(name)
$scene = Scene_Keep_Item.new(name)
$scene.main
end
end
end
class Interpreter
include Scene_Keep_Item::Event_Script
end
# Scene_Keep_Item
Also, do you make your own scripts?