MCsephiroth13
Member
I have these two scripts that Brewmeister brewed for me that have slight issues. First, let me explain what the scripts are supposed to do. One script is a window class that goes with a Scene. The Scene opens a window that contains items that you specify when calling the script through an event command. The player can choose which items he wants by selecting them. The only problem is that the items just stay there after you select them, instead of leaving the scene. They still enter your inventory, but since they don't go away, the player can keep clicking on them infinitely.
I need for the script to get rid of the items that you select and when you exit the scene, the items are still gone once the scene is re-called. Like, if I want the scene to be called with the initial items of A and B, the player will take item A then leave. He then opens it again and only item B is there.
Here's the window script:
and here's the scene script:
I will be extremely grateful to whoever can help me with this. Thanks.
I need for the script to get rid of the items that you select and when you exit the scene, the items are still gone once the scene is re-called. Like, if I want the scene to be called with the initial items of A and B, the player will take item A then leave. He then opens it again and only item B is there.
Here's the window script:
Code:
#==============================================================================
# ** Window_Chest
#------------------------------------------------------------------------------
# This window displays items in a chest
#==============================================================================
class Window_Chest < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(items, weapons, armor)
super(270, 54, 240, 380)
@column_max = 1
@items = items
@weapons = weapons
@armor = armor
refresh
self.index = 0
self.back_opacity = 160
# If in battle, move window to center of screen
# and make it semi-transparent
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Add item
for i in [email=0...@items.size]0...@items.size[/email]
@data.push($data_items[@items[i]])
end
# Add weapons and Armor
for i in [email=0...@weapons.size]0...@weapons.size[/email]
@data.push($data_weapons[@weapons[i]])
end
for i in [email=0...@armor.size]0...@armor.size[/email]
@data.push($data_armors[@armor[i]])
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 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.draw_text(x + 28, y, 212, 32, item.name, 0)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
and here's the scene script:
Code:
#==============================================================================
# ** Scene_Chest
#------------------------------------------------------------------------------
# This class performs chest screen processing.
# Call with:
# $scene = Scene_Chest.new([items],[weapons],[armor])
# EX:
# $scene = Scene_Chest.new([1,2,3],[1,2,3],[1,2,3])
# Use an empty array [] if no object of that type
# EX:
# $scene = Scene_Chest.new([1,2,3],[],[1,2,3])
#==============================================================================
class Scene_Chest
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize(items, weapons, armor)
@items = items
@weapons = weapons
@armor = armor
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make menu background
@spriteset = Spriteset_Map.new
@item_window = Window_Chest.new(@items, @weapons, @armor)
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@item_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@item_window.update
update_item
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
@item = @item_window.item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Add the item to the inventory
case @item
when RPG::Item
$game_party.gain_item(@item.id, 1)
# Draw item window item
@item_window.draw_item(@item_window.index)
when RPG::Weapon
$game_party.gain_weapon(@item.id, 1)
# Draw item window item
@item_window.draw_item(@item_window.index)
when RPG::Armor
$game_party.gain_armor(@item.id, 1)
# Draw item window item
@item_window.draw_item(@item_window.index)
end
end
end
end
I will be extremely grateful to whoever can help me with this. Thanks.