Problem: Game crashes when I open the menu the second time.
I can open my custem menu once and every thing is ok but the second time I open it the game crashes. No Errors
The script.
I can open my custem menu once and every thing is ok but the second time I open it the game crashes. No Errors
The script.
Code:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@spritesetmap = Spriteset_Map.new
# Make command window
s1 = "New Tattie"
s2 = "Random Tattie"
s3 = "Save Tattie"
s4 = "Load Tattie"
s5 = "Name Tattie"
s6 = "Exit Menu"
s7 = "Exit Game"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
@command_window.index = @menu_index
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
@command_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$game_temp.common_event_id = 1
$scene = Scene_Map.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$game_temp.common_event_id = 2
$scene = Scene_Map.new
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$scene = Scene_Save.new
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$loadp = 1
$scene = Scene_Load.new
when 4 # Party
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$scene = Scene_Name.new
when 5 # Common Event
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$scene = Scene_Map.new
when 6 # save
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$game_temp.common_event_id = 1
$scene = Scene_Map.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$game_temp.common_event_id = 2
$scene = Scene_Map.new
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$scene = Scene_Save.new
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$scene = Scene_Load.new
when 4 # Party
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$scene = Scene_Name.new
when 5 # Common Event
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$scene = Scene_Map.new
when 6 # save
$scene = Scene_End.new
end
return
end
end
end