Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Selectable window menu thingy

I am making a sort of "pet system". Right now I am making the sort of selectable menu to go at the side of the screen while in the pet scene, but I am having some problems.

I tried Dubealex's selectable menu tutorial bit but found it absolutely crap (it doesn't explain anything, just says "copy and paste this into here and you have yourself a menu" pretty much... Or that's what it seemed to me.)

So i decided to sort of er... look for bits and pieces that seemed like parts of a selectable menu from Scene_Menu and er... added them in to my script. I know, I am a noob at RGSS.

Code:
class Scene_PetSystem
  #-----------------
  # Main processing
  #-----------------

  def main
    # Make command window
    s1 = "Pets"
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    @command_window = Window_Command.new(185, [s1, s2, s3, s4])
    @command_window.index = @menu_index
    #Call windows
    @window1 = Window_Pets1.new
    @window2 = Window_Pets2.new
    #@window3 = Window_Pets3.new
    #@window4 = Window_Pets4.new
    @window5 = Window_Pets5.new
    #Transition
    Graphics.transition
    #Main loop
    loop do
    #Update game screen
    Graphics.update
    #Update input info
    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
  @window1.dispose
  @window2.dispose
  #@window3.dispose
  #@window4.dispose
  @window5.dispose
  @command_window.dispose
end

#-------------------
# Frame update
#-------------------

  def update
    #Update windows
    @command_window.update
    @window1.update
    @window2.update
    #@window3.update
    #@window4.update
    @window5.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 menu screen
      $scene = Scene_Menu.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0  # Change Name
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        #Syntax for 'Change Name'
        $scene = Scene_Menu.new
      when 1  # Pet Store
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        #Syntax for 'Pet Store'
        $scene = Scene_Menu.new
      when 2  # Battlegrounds
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        #Syntax for 'Battlegrounds'
        $scene = Scene_Menu.new
      when 3  # Back to Menu
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        #Syntax for 'Back to Menu'
        $scene = Scene_Menu.new
      end
      return
    end
  end
end

As you can er... probably guess I am having a lot of errors...

Are there any sort of guides or anything for making a selectable window? Or er... anyone know what I have done wrong in the scene above?
 
I have changed the script a bit, been working on it. Got rid of 2 windows for example and stuff. But anyway, this is it:

Code:
#===============================================================================
# Scene_PetSystem
#===============================================================================

class Scene_PetSystem
  #-----------------
  # Main processing
  #-----------------

  def main
    #Call windows
    @window1 = Window_Pets1.new
    @window2 = Window_Pets2.new
    @window3 = Window_Pets3.new
    #Transition
    Graphics.transition
    #Main loop
    loop do
    #Update game screen
    Graphics.update
    #Update input info
    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
  @window1.dispose
  @window2.dispose
  @window3.dispose
end

#-------------------
# Frame update
#-------------------

  def update
    #Update windows
    @window1.update
    @window2.update
    @window3.update
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to Menu screen
      $scene = Scene_Menu.new
      return
    end
  end
end

#===============================================================================
# Window_Pets1
# ------------------------------------------------------------------------------
# This is the status window
#===============================================================================

class Window_Pets1 < Window_Base
  #--------------------------------------------------------------------------
  # Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 120, 32, "Name:")
    self.contents.draw_text(90, 0, 120, 32, $data_actors[2].name)
    self.contents.draw_text(0, 32, 120, 32, "Type:")
    self.contents.draw_text(0, 64, 120, 32, "Level:")
    self.contents.draw_text(0, 96, 120, 32, "Health:")
  #Pet types
    if $game_variables[13] == 0
      self.contents.draw_text(90, 32, 300, 32, "You have no pet.")
    else
      if $game_variables[13] == 1
        self.contents.draw_text(90, 32, 300, 32, "Alsatchie")
      else 
        if $game_variables[13] == 2
          self.contents.draw_text(90, 32, 300, 32, "Myainn")
        else 
          if $game_variables[13] == 3
            self.contents.draw_text(90, 32, 300, 32, "Tigra")
          else 
            if $game_variables[13] == 4
              self.contents.draw_text(90, 32, 300, 32, "Ephanti")
            end
          end
        end
      end
    end
  end
end

#===============================================================================
# Window_Pets2
# ------------------------------------------------------------------------------
# This is the random pet message window
#===============================================================================

class Window_Pets2 < Window_Base
  #--------------------------------------------------------------------------
  # Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 160, 640, 60)
    self.contents = Bitmap.new(width - 0, height - 0)
    refresh
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    #-------------------------
    #Random message generator
    #-------------------------
    if $game_variables[11] == 0
      self.contents.draw_text(0, 0, 500, 32, "Your pet is very happy to see you.")
    else 
      if $game_variables[11] == 1
        self.contents.draw_text(0, 0, 500, 32, "Your pet is feeling very lonely.")
      else 
        if $game_variables[11] == 2
          self.contents.draw_text(0, 0, 500, 32, "Your pet wants to fight someone!")
        else 
          if $game_variables[11] == 3
            self.contents.draw_text(0, 0, 500, 32, "Your pet thinks you should buy it a new toy.")
          else 
            if $game_variables[11] == 4
              self.contents.draw_text(0, 0, 500, 32, "Your pet is feeling hungry.")
            else 
              if $game_variables[11] == 5
                self.contents.draw_text(0, 0, 500, 32, "Your pet likes the name you chose them!")
              end
            end
          end
        end
      end
    end
  end
end

#===============================================================================
# Window_Pets3
# ------------------------------------------------------------------------------
# This is the status window
#===============================================================================

class Window_Pets3 < Window_Base
  #--------------------------------------------------------------------------
  # Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(185, 220, 455, 260)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    if $game_variables[12] == 0
      self.contents.draw_text(0, 0, 500, 32, "You can change your pet's name")
      self.contents.draw_text(0, 32, 500, 32, "at any time by choosing the 'change name'")
      self.contents.draw_text(0, 64, 500, 32, "option from the menu in this screen.")
      self.contents.draw_text(0, 128, 500, 32, "This will give your pet more originality !")
    else 
      if $game_variables[12] == 1
      self.contents.draw_text(0, 0, 500, 32, "Your pet's health is important!")
      self.contents.draw_text(0, 64, 500, 32, "Make sure you feed them often")
      self.contents.draw_text(0, 96, 500, 32, "enough to keep them fit and healthy.")
      else 
        if $game_variables[12] == 2
          self.contents.draw_text(0, 0, 500, 32, "Pets are noble fighters.")
          self.contents.draw_text(0, 64, 500, 32, "They will often fight in their owners'")
          self.contents.draw_text(0, 96, 500, 32, "honour in the pets battle ground!")
        else 
          if $game_variables[12] == 3
            self.contents.draw_text(0, 0, 500, 32, "Pets make good companions.")
            self.contents.draw_text(0, 64, 500, 32, "Make sure you look after your pet, and")
            self.contents.draw_text(0, 96, 500, 32, "feed it at the right times. Remember that")
            self.contents.draw_text(0, 128, 500, 32, "Your pet will want some rest after battling!")
          end
        end
      end
    end
  end
end

Basically I wanted in the space left for there to be a selectable window with:

Change name
Pet store
Battlegrounds
Back to Menu
 
EDIT: Nevermind fixed the error this particular post was about. Anyway, I still need someway of making a selectable thingy...

I am going to ask someone to if they will make one in script requests.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top