Sobeman459
Member
I've hit a snag while coding this, and please pardon my horrible code. Anyway what i want to happen is when you select an item say a potion you get a command window saying use or cancel. Use you use the item and cancel takes you back to @Items.visible = true. Now im having trouble in Window_Selectible. I have no idea were i went wrong. Any help would be greatly appreciated.
PS: This script is no where near done only working on the items screen right now.
-SoBe
PPS: If you need the windows for the menu i can post those also. Thank you!
PS: This script is no where near done only working on the items screen right now.
-SoBe
Code:
#==============================================================================
# ** Scene_Menu_SoBe
#------------------------------------------------------------------------------
# Â Menu System
#==============================================================================
Â
class Scene_Menu_SoBe
 def initialize(item_index = 1)
  @item_index = item_index
 end
 #--------------------------------------------------------------------------
 # * Scene Processing
 #--------------------------------------------------------------------------
 def main
  # Make sprite set
  @spriteset = Spriteset_Map.new
  # Info Window
  @Info = Window_Info.new
  # Fraction Window
  @Frac = Window_Frac.new
  @Frac.visible = false
  # Item Window
  @Items = Window_Items.new
  @Items.visible = true
  # Quest Window
  @Quest = Window_Quest.new
  @Quest.visible = false
  # Equip Window
  @Equip = Window_Equip.new
  @Equip.visible = false
  # Stats Window
  @Stats = Window_Stats.new
  @Stats.visible = false
  # World Map Window
  @WMap = Window_WMap.new
  @WMap.visible = false
  # Skill Window
  @Skill = Window_Skill.new
  @Skill.visible = false
  # Make target window (set to invisible / inactive)
  s1 = "Use"
  s2 = "Cancel"
  @target_window = Window_Command.new(160, [s1, s2])
  @target_window.index = @menu_index
  @target_window.visible = false
  @target_window.active = false
  # Transition run
  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 sprite set
  @spriteset.dispose
  @Frac.dispose
  @Items.dispose
  @Equip.dispose
  @Stats.dispose
  @Quest.dispose
  @WMap.dispose
  @Skill.dispose
  @Info.dispose
  @target_window.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
  # Update sprite set
  @spriteset.update
  @Frac.update
  @Items.update
  @Equip.update
  @Stats.update
  @Quest.update
  @WMap.update
  @Skill.update
  @Info.update
  @target_window.update
  if @Frac.visible == true
   update_frac
   return
  end
  if @Items.visible == true
   update_items
   return
  end
  if @Equip.visible == true
   update_equip
   return
  end
  if @Stats.visible == true
   update_stats
   return
  end
  if @Quest.visible == true
   update_quest
   return
  end
  if @WMap.visible == true
   update_wmap
   return
  end
  if @Skill.visible == true
   update_skill
   return
  end
 end
 #--------------------------------------------------------------------------
 # * Frame Update Items
 #--------------------------------------------------------------------------
 def update_items
  # If item window is active: call update_item
  if @Items.active
   update_item
   return
  end
  # If target window is active: call update_target
  if @target_window.active
   update_target
   return
  end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when item window is active)
 #--------------------------------------------------------------------------
 def update_item
  # If R button was pressed
  if Input.trigger?(Input::RIGHT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Items.visible = false
   @Equip.visible = true
   return
  end
  # If L button was pressed
  if Input.trigger?(Input::LEFT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Items.visible = false
   @WMap.visible = true
   return
  end
  # 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)
   # Get currently selected data on the item window
   @item = @Items.item
   # If not a use item
   unless @item.is_a?(RPG::Item)
    # Play buzzer SE
    $game_system.se_play($data_system.buzzer_se)
    return
   end
   # If it can't be used
   unless $game_party.item_can_use?(@item.id)
    # Play buzzer SE
    $game_system.se_play($data_system.buzzer_se)
    return
   end
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # If effect scope is an ally
   if @item.scope >= 3
    # Activate target window
    @Items.active = false
    @target_window.visible = true
    @target_window.active = true
    # Set cursor position to effect scope (single / all)
    if @item.scope == 4 || @item.scope == 6
     @target_window.index = -1
    else
     @target_window.index = 0
    end
   # If effect scope is other than an ally
   else
    # If command event ID is valid
    if @item.common_event_id > 0
     # Command event call reservation
     $game_temp.common_event_id = @item.common_event_id
     # Play item use SE
     $game_system.se_play(@item.menu_se)
     # If consumable
     if @item.consumable
      # Decrease used items by 1
      $game_party.lose_item(@item.id, 1)
      # Draw item window item
      @item_window.draw_item(@item_window.index)
     end
     # Switch to map screen
     $scene = Scene_Map.new
     return
    end
   end
   return
  end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when target window is active)
 #--------------------------------------------------------------------------
 def update_target
  # If B button was pressed
  if Input.trigger?(Input::B)
   # Play cancel SE
   $game_system.se_play($data_system.cancel_se)
   # If unable to use because items ran out
   unless $game_party.item_can_use?(@item.id)
    # Remake item window contents
    @item_window.refresh
   end
   # Erase target window
   @Items.active = true
   @target_window.visible = false
   @target_window.active = false
   return
  end
  # If C button was pressed
  if Input.trigger?(Input::C)
   # If items are used up
   if $game_party.item_number(@item.id) == 0
    # Play buzzer SE
    $game_system.se_play($data_system.buzzer_se)
    return
   end
   # If target is all
   if @target_window.index == -1
    # Apply item effects to entire party
    used = false
    for i in $game_party.actors
     used |= i.item_effect(@item)
    end
   end
   # If single target
   if @target_window.index >= 0
    # Apply item use effects to target actor
    target = $game_party.actors[@target_window.index]
    used = target.item_effect(@item)
   end
   # If an item was used
   if used
    # Play item use SE
    $game_system.se_play(@item.menu_se)
    # If consumable
    if @item.consumable
     # Decrease used items by 1
     $game_party.lose_item(@item.id, 1)
     # Redraw item window item
     @Items.draw_item(@Items.index)
    end
    # Remake target window contents
    @target_window.refresh
    # If all party members are dead
    if $game_party.all_dead?
     # Switch to game over screen
     $scene = Scene_Gameover.new
     return
    end
    # If common event ID is valid
    if @item.common_event_id > 0
     # Common event call reservation
     $game_temp.common_event_id = @item.common_event_id
     # Switch to map screen
     $scene = Scene_Map.new
     return
    end
   end
   # If item wasn't used
   unless used
    # Play buzzer SE
    $game_system.se_play($data_system.buzzer_se)
   end
   return
  end
 end
 #--------------------------------------------------------------------------
 # * Frame Update Equip
 #--------------------------------------------------------------------------
 def update_equip
  # If R button was pressed
  if Input.trigger?(Input::RIGHT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Equip.visible = false
   @Stats.visible = true
   return
  end
  # If L button was pressed
  if Input.trigger?(Input::LEFT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Equip.visible = false
   @Items.visible = true
   return
  end
 end
 #--------------------------------------------------------------------------
 # * Frame Update Stats
 #--------------------------------------------------------------------------
 def update_stats
  # If R button was pressed
  if Input.trigger?(Input::RIGHT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Stats.visible = false
   @Frac.visible = true
   return
  end
  # If L button was pressed
  if Input.trigger?(Input::LEFT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Stats.visible = false
   @Equip.visible = true
   return
  end
 end
 #--------------------------------------------------------------------------
 # * Frame Update Frac
 #--------------------------------------------------------------------------
 def update_frac
  # If R button was pressed
  if Input.trigger?(Input::RIGHT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Frac.visible = false
   @Quest.visible = true
   return
  end
  # If L button was pressed
  if Input.trigger?(Input::LEFT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Frac.visible = false
   @Stats.visible = true
   return
  end
 end
 #--------------------------------------------------------------------------
 # * Frame Update Quest
 #--------------------------------------------------------------------------
 def update_quest
  # If R button was pressed
  if Input.trigger?(Input::RIGHT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Quest.visible = false
   @Skill.visible = true
   return
  end
  # If L button was pressed
  if Input.trigger?(Input::LEFT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Quest.visible = false
   @Frac.visible = true
   return
  end
 end
 #--------------------------------------------------------------------------
 # * Frame Update Skill
 #--------------------------------------------------------------------------
 def update_skill
  # If R button was pressed
  if Input.trigger?(Input::RIGHT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Skill.visible = false
   @WMap.visible = true
   return
  end
  # If L button was pressed
  if Input.trigger?(Input::LEFT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @Skill.visible = false
   @Quest.visible = true
   return
  end
 end
 #--------------------------------------------------------------------------
 # * Frame Update WMap
 #--------------------------------------------------------------------------
 def update_wmap
  # If R button was pressed
  if Input.trigger?(Input::RIGHT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @WMap.visible = false
   @Items.visible = true
   return
  end
  # If L button was pressed
  if Input.trigger?(Input::LEFT)
   # Play cursor SE
   $game_system.se_play($data_system.cursor_se)
   @WMap.visible = false
   @Skill.visible = true
   return
  end
 end
end
PPS: If you need the windows for the menu i can post those also. Thank you!