Jeff the Green
Member
My game has a different way of handling weapons than in the standard scripts, so I wrote a script for a shop specifically designed to handle these weapons. First I made the windows (and made sure each of them worked by themselves), but once I put them into a Scene, none of them appears.
I also played around with it a little and found that, if I get rid of the disposing commands when the game shifts to a new scene, the windows suddenly and inexplicably appear if I go back to the map (or, rather, press the buttons that would take me back to the map, since it never disappears). Also, everything else happens: sound effects are played, variables are changed, all the different update defs work (I tested using "p"). Only the windows don't work, and I'm absolutely baffled since it's almost a copy and paste job of the standard shop.
Here's the link to my project, since there are several scripts and databases the script it relies on and you can't just cut and paste it, but here's the scene script, since that's what appears to be causing the problem:
Edit:
I solved the problem with some help from someone from Phanxgames. If anyone has trouble like this and finds this thread, don't forget to include "Graphics.transition" after creating the windows and before your main loop.
I also played around with it a little and found that, if I get rid of the disposing commands when the game shifts to a new scene, the windows suddenly and inexplicably appear if I go back to the map (or, rather, press the buttons that would take me back to the map, since it never disappears). Also, everything else happens: sound effects are played, variables are changed, all the different update defs work (I tested using "p"). Only the windows don't work, and I'm absolutely baffled since it's almost a copy and paste job of the standard shop.
Here's the link to my project, since there are several scripts and databases the script it relies on and you can't just cut and paste it, but here's the scene script, since that's what appears to be causing the problem:
Code:
#==============================================================================
# ** Scene_CrystalShop
#------------------------------------------------------------------------------
# This class performs crystal shop processing.
#==============================================================================
class Scene_CrystalShop
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get shop name
@shop_name = $game_temp.crystal_shop
# Make help window
@help_window = Window_Help.new
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 64
# Make dummy window
@dummy_window = Window_Base.new(0, 128, 640, 352)
# Make command window
@command_window = Window_CrystalShopCommand.new
# Make buy window
@buy_window = Window_CrystalShopBuy.new
@buy_window.shop_name = @shop_name
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
# Make sell window
@sell_window = Window_CrystalShopSell.new
@sell_window.shop_name = @shop_name
@sell_window.visible = false
@sell_window.active = false
@sell_window.help_window = @help_window
# Make right window
@status_window = Window_CrystalShopRight.new
# Make Buy/Sell/Cancel window
@yesno_window = Window_CrystalShopYesNo.new
@yesno_window.visible = false
@yesno_window.active = false
# Make decide window
@decide_window = Window_CrystalShopDecide.new
@decide_window.visible = false
# 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
@help_window.dispose
@gold_window.dispose
@dummy_window.dispose
@command_window.dispose
@buy_window.dispose
@sell_window.dispose
@status_window.dispose
@yesno_window.dispose
@decide_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@help_window.update
@gold_window.update
@dummy_window.update
@command_window.update
@buy_window.update
@sell_window.update
@status_window.update
@yesno_window.update
@decide_window.update
# If command window is active : call update_command
if @command_window.active
update_command
return
end
# If buy window is active : call update_command
if @buy_window.active
update_buy
return
end
# If sell window is active : call update_sell
if @sell_window.active
update_sell
return
end
# If yes/no window is active : call update_yesno
if @yesno_window.active
update_yesno
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)
# Branch by command window cursor position
case @command_window.index
when 0 # buy
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Change windows to buy mode
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
when 1 # sell
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Change windows to sell mode
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = true
@sell_window.refresh
when 2 # quit
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to map screen
$scene = Scene_Map.new
end
return
end
return
end
#--------------------------------------------------------------------------
# * Frame Update (when buy window is active)
#--------------------------------------------------------------------------
def update_buy
# Update help
@buy_window.update_help
# Set right window item
@status_window.item = @buy_window.item
# If B button was pressed
if Input.trigger?(Input::B)
# Change windows to command mode
@command_window.active = true
@buy_window.visible = false
@buy_window.active = false
@status_window.visible = false
@dummy_window.visible = true
@status_window.item = nil
# Erase help text
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::B)
# Get item
item = @buy_item.item
# If item is equipped
if item.equipped?
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Change windows to yes/no mode
@buy_window.active = false
@yesno_window.action = 'buy'
@yesno_window.active = true
@yesno_window.visible = true
@decide_window.visible = true
@decide_window.item = @buy_window.item
@yesno_window.refresh
@decide_window.refresh
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when sell window is active)
#--------------------------------------------------------------------------
def update_sell
# Update help
@sell_window.update_help
# Set right window item
@status_window.item = @sell_window.item
# If B button was pressed
if Input.trigger?(Input::B)
# Change windows to command mode
@command_window.active = true
@sell_window.visible = false
@sell_window.active = false
@status_window.visible = false
@dummy_window.visible = true
@status_window.item = nil
# Erase help text
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::C)
price = @sell_window.item.price * $game_crystalshops[@shop_name].sell_rate
if price > $game_party.gold
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Change windows to yes/no mode
@sell_window.active = false
@yesno_window.action = 'sell'
@yesno_window.active = true
@yesno_window.visible = true
@decide_window.visible = true
@decide_window.item = @buy_window.item
@yesno_window.refresh
@decide_window.refresh
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when yes/no window is active)
#--------------------------------------------------------------------------
def update_yesno
# If B button was pressed
if Input.trigger?(Input::B)
# Revert to sell or buy mode
@yesno_window.visible = false
@yesno_window.active = false
@decide_window.visible = false
if @yesno_window.action = 'sell'
@sell_window.active = true
else
@buy_window.active = true
end
@yesno_window.action = nil
return
end
# If C button was pressed
if Input.trigger?(Input::B)
# If chose to buy or sell
if @yesno_window.index = 0
# If buying
if @yesno_window.action = 'buy'
$game_crystalshops[@shopname].buy(@buy_window.item)
# If selling
else
$game_crystalshops[@shopname].sell(@sell_window.item)
end
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Regardless of choice, revert to sell or buy mode
@yesno_window.visible = false
@yesno_window.active = false
@decide_window.visible = false
if @yesno_window.action = 'sell'
@sell_window.active = true
else
@buy_window.active = true
end
@yesno_window.action = nil
return
end
end
end
Edit:
I solved the problem with some help from someone from Phanxgames. If anyone has trouble like this and finds this thread, don't forget to include "Graphics.transition" after creating the windows and before your main loop.