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.

CMS: updating a window

I have this bit of code as my menu scene:

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

# ** Scene_Inventory

#------------------------------------------------------------------------------

#  This class performs inventory screen processing.

#==============================================================================

 

class Scene_Inventory

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     menu_index : command cursor's initial position

  #--------------------------------------------------------------------------

  def initialize(menu_index = 0)

    @menu_index = menu_index

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    # Get actor for status window

    @actor = $game_party.actors[@menu_index]

    # Make command window

    s1 = $data_system.words.item

    s2 = $data_system.words.skill

    s3 = $data_system.words.equip

    @command_window = Window_Command.new(72 + 32, [s1, s2, s3])

    @command_window.index = @menu_index

    @command_window.back_opacity = 230

    # If number of party members is 0

    if $game_party.actors.size == 0

      # Disable items, skills, equipment, and status

      @command_window.disable_item(0)

      @command_window.disable_item(1)

      @command_window.disable_item(2)

    end

    # Make target window

    @target_window = Window_MenuTarget.new

    @target_window.x = 0

    @target_window.y = 160

    @target_window.opacity = 230

    # Make status window

    @status_window = Window_Status.new(@actor)

    @status_window.x = 72 + 32

    @status_window.y = 0

    @status_window.opacity = 230

    # Show map as background

    @spriteset = Spriteset_Map.new

    # 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

    @command_window.dispose

    @target_window.dispose

    @status_window.dispose

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Update windows

    @command_window.update

    @target_window.update

    @status_window.update

    # If command window is active: call update_command

    if @command_window.active

      update_command

      return

    end

    # If target window is active: call update_target & update_status

    if @target_window.active

      update_target

      update_status

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (when command window is active)

  #--------------------------------------------------------------------------

  def update_command

    # If A button was pressed

    if Input.trigger?(Input::A)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to map screen

      $scene = Scene_Map.new

      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)

      # 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

        $scene = Scene_Item.new

      when 1  # skill

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Make target window active

        @command_window.active = false

        @target_window.active = true

        @target_window.index = 0

      when 2  # equipment

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Make target window active

        @command_window.active = false

        @target_window.active = true

        @target_window.index = 0

      end

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (when target window is active)

  #--------------------------------------------------------------------------

  def update_target

    # If A button was pressed

    if Input.trigger?(Input::A)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Make command window active

      @command_window.active = true

      @target_window.active = false

      @target_window.index = -1

      return

    end

    # 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

      @target_window.active = false

      @target_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 1  # skill

        # If this actor's action limit is 2 or more

        if $game_party.actors[@target_window.index].restriction >= 2

          # Play buzzer SE

          $game_system.se_play($data_system.buzzer_se)

          return

        end

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to skill screen

        $scene = Scene_Skill.new(@target_window.index)

      when 2  # equipment

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to equipment screen

        $scene = Scene_Equip.new(@target_window.index)

      end

      return

    end

  end

  def update_status

    # ???

  end

end

 
The problem is that I don't know what to put in the 'update_status' method to get the player status window to show the stats of the player defined by the cursor index of 'window_target'.

I'm not sure if my explanation makes any sense. In other words, the idea is that in the main menu screen I would have the command window (with 3 commands: Items, Skills and Equip) and below it a target window (which activates when selecting Skills or Equip from command window). The target window is just the default Window_MenuStatus class with nothing but a 72x72 picture of the character. When the target window is activated, a status window would appear next to it, showing the stats of the player to which the cursor of the target window is pointing. Whew... I hope you get the idea. And thanks in advance!
 
I'm not 100% sure what your asking but I think I've got a good idea, you want images 72x72 of the character working as a command window, so when you select a character image you can pick Skills/Equip for them? If this is all you want to do you'd have to define the images some where that will be used for the character images and make them into a command window. Then it would be a simple case of updating them like every other image/window
Code:
definedimagex.update
Now I'm not entirly sure if I'm correct with this either so this may or may not work.
 
Nononono... I've already got that part covered. I have selectable window with the images. Thanks for trying, anyway! :grin:

Just look at the code I posted, the last method, 'update_status', where it says ???. That's the problem. I need to update the status window according to the index of the target window. Like this:
mockup.png
 
Yes, that's what I've done.

Actually I've probably been thinking this whole thing wrong. :|: I need to modify the 'update_target' method (frame update when target window is active) so, that it gets the @actor variable for the Window_Status.


EDIT#1: Damn... I added this to 'update_target' in Scene_Menu:
Code:
 

# Get actor

    @actor = $game_party.actors[@actor_index]
Now if I select Equip or Skills (= try to activate 'target_window') the game crashes, saying "No implicit conversion from nil to integer." AAArgh!

EDIT#2: Ok, the last edit was stupid. Now this is what I got:

The main menu scene:
Code:
#==============================================================================

# ** Scene_Menu

#------------------------------------------------------------------------------

#  This class performs menu screen processing.

#==============================================================================

 

class Scene_Inventory

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     menu_index : command cursor's initial position

  #--------------------------------------------------------------------------

  def initialize(menu_index = 0)

    @menu_index = menu_index

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    # Make command window

    s1 = $data_system.words.item

    s2 = $data_system.words.skill

    s3 = $data_system.words.equip

    @command_window = Window_Command.new(72 + 32, [s1, s2, s3])

    @command_window.index = @menu_index

    @command_window.back_opacity = 230

    # If number of party members is 0

    if $game_party.actors.size == 0

      # Disable items, skills, equipment, and status

      @command_window.disable_item(0)

      @command_window.disable_item(1)

      @command_window.disable_item(2)

    end

    # Make target window

    @target_window = Window_MenuTarget.new

    @target_window.x = 0

    @target_window.y = 160

    @target_window.opacity = 230

    # Make status window

    @status_window = Window_Status.new(@target_window.index)

    @status_window.x = 72 + 32

    @status_window.y = 0

    @status_window.opacity = 230

    # Show map as background

    @spriteset = Spriteset_Map.new

    # 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

    @command_window.dispose

    @target_window.dispose

    @status_window.dispose

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Update windows

    @command_window.update

    @target_window.update

    @status_window.update

    # If command window is active: call update_command

    if @command_window.active

      update_command

      return

    end

    # If target window is active: call update_target

    if @target_window.active

      update_target

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (when command window is active)

  #--------------------------------------------------------------------------

  def update_command

    # If A button was pressed

    if Input.trigger?(Input::A)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to map screen

      $scene = Scene_Map.new

      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)

      # If command other than save or end game, and party members = 0

      if $game_party.actors.size == 0 and @command_window.index < 3

        # 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

        $scene = Scene_Item.new

      when 1  # skill

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Make target window active

        @command_window.active = false

        @target_window.active = true

        @target_window.index = 0

      when 2  # equipment

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Make target window active

        @command_window.active = false

        @target_window.active = true

        @target_window.index = 0

      end

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (when target window is active)

  #--------------------------------------------------------------------------

  def update_target

    # If A button was pressed

    if Input.trigger?(Input::A)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Make command window active

      @command_window.active = true

      @target_window.active = false

      @target_window.index = -1

      return

    end

    # 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

      @target_window.active = false

      @target_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 1  # skill

        # If this actor's action limit is 2 or more

        if $game_party.actors[@target_window.index].restriction >= 2

          # Play buzzer SE

          $game_system.se_play($data_system.buzzer_se)

          return

        end

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to skill screen

        $scene = Scene_Skill.new(@target_window.index)

      when 2  # equipment

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to equipment screen

        $scene = Scene_Equip.new(@target_window.index)

      end

      return

    end

  end

end

 

In the status window:
Code:
# WINDOW_STATUS ================================================================

 

class Window_Status < Window_Base

 

  # Object Initialization ------------------------------------------------------

  #    actor : actor

  def initialize(actor)

    super(0, 0, 296, 480)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.opacity = 230

    @actor = actor

    refresh

  end

 

  # Refresh --------------------------------------------------------------------

  def refresh

    self.contents.clear

    if @actor != -1

      self.contents.font.color = system_color

      self.contents.font.size = 20

      self.contents.draw_text(0, 0, contents.width, 24, @actor.name)

      self.contents.font.size = 18

      self.contents.draw_text(0, 24, contents.width, 24, "Faction:")

    # money_width = self.contents.text_size($game_party.gold.to_s).width

    # self.contents.draw_text(money_width + 4, 72, contents.width, 24, "$")

      self.contents.draw_text(26, 240, contents.width, 24, "ATK")

      self.contents.draw_text(26, 264, contents.width, 24, "ACC")

      self.contents.draw_text(26, 288, contents.width, 24, "CDEF")

      self.contents.draw_text(26, 312, contents.width, 24, "EDEF")

      self.contents.draw_text(26, 336, contents.width, 24, "STR")

      self.contents.draw_text(26, 360, contents.width, 24, "END")

      self.contents.draw_text(26, 384, contents.width, 24, "AGI")

      self.contents.draw_text(26, 408, contents.width, 24, "PER")

      # Draw values

      self.contents.font.color = normal_color

      self.contents.draw_text(72, 24, contents.width, 24, @actor.class_name)

      self.contents.draw_text(70, 240, contents.width, 24, @actor.atk.to_s)

      self.contents.draw_text(70, 264, contents.width, 24, @actor.hit.to_s)

      self.contents.draw_text(70, 288, contents.width, 24, @actor.pdef.to_s)

      self.contents.draw_text(70, 312, contents.width, 24, @actor.mdef.to_s)

      self.contents.draw_text(70, 336, contents.width, 24, @actor.str.to_s)

      self.contents.draw_text(70, 360, contents.width, 24, @actor.dex.to_s)

      self.contents.draw_text(70, 384, contents.width, 24, @actor.agi.to_s)

      self.contents.draw_text(70, 408, contents.width, 24, @actor.int.to_s)

      # Draw icons

      bitmap = RPG::Cache.icon("icon_symbol_attack")

      self.contents.blt(0, 240, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_accuracy")

      self.contents.blt(0, 264, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_cdef")

      self.contents.blt(0, 288, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_edef")

      self.contents.blt(0, 312, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_strength")

      self.contents.blt(0, 336, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_endura")

      self.contents.blt(0, 360, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_agility")

      self.contents.blt(0, 384, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_percept")

      self.contents.blt(0, 408, bitmap, Rect.new(0, 0, 24, 24), 200)

      # Draw condition icons

      if @actor.states.include?(1)

        bitmap = RPG::Cache.icon("icon_symbol_critical")

        self.contents.blt(0, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_critical_g")

        self.contents.blt(0, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(2)

        bitmap = RPG::Cache.icon("icon_symbol_blood")

        self.contents.blt(24, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_blood_g")

        self.contents.blt(24, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(3)

        bitmap = RPG::Cache.icon("icon_symbol_fire")

        self.contents.blt(48, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_fire_g")

        self.contents.blt(48, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(4)

        bitmap = RPG::Cache.icon("icon_symbol_hunger")

        self.contents.blt(72, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_hunger_g")

        self.contents.blt(72, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(5)

        bitmap = RPG::Cache.icon("icon_symbol_toxic")

        self.contents.blt(96, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_toxic_g")

        self.contents.blt(96, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(6)

        bitmap = RPG::Cache.icon("icon_symbol_bio")

        self.contents.blt(120, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_bio_g")

        self.contents.blt(120, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(7)

        bitmap = RPG::Cache.icon("icon_symbol_rad")

        self.contents.blt(144, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_rad_g")

        self.contents.blt(144, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(8)

        bitmap = RPG::Cache.icon("icon_symbol_psi")

        self.contents.blt(168, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_psi_g")

        self.contents.blt(168, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      # Show level

      bitmap = RPG::Cache.icon("icon_symbol_level")

      self.contents.blt(0, 120, bitmap, Rect.new(0, 0, 24, 24), 200)

      self.contents.draw_text(26, 120, contents.width, 24, "L")

      self.contents.draw_text(70, 120, contents.width, 24, @actor.level.to_s)

      # Show exp bar

      bitmap = RPG::Cache.icon("icon_symbol_xp")

      self.contents.blt(0, 144, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 144, bitmap, Rect.new(0, 0, 240, 24), 60)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 144, bitmap, Rect.new(0, 0, (@actor.exp.to_f / @actor.next_exp.to_f) * 240, 24), 140)

      self.contents.draw_text(26, 144, contents.width, 24, "XP")

      self.contents.draw_text(70, 144, contents.width, 24, @actor.exp_s + "/" + @actor.next_rest_exp_s)

      # Show hp bar

      bitmap = RPG::Cache.icon("icon_symbol_health")

      self.contents.blt(0, 168, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 168, bitmap, Rect.new(0, 0, 240, 24), 60)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 168, bitmap, Rect.new(0, 0, (@actor.hp.to_f / @actor.maxhp.to_f) * 240, 24), 140)

      self.contents.draw_text(26, 168, contents.width, 24, "HP")

      self.contents.draw_text(70, 168, contents.width, 24, @actor.hp.to_s + "/" + @actor.maxhp.to_s)

      # Show fp bar

      bitmap = RPG::Cache.icon("icon_symbol_fatigue")

      self.contents.blt(0, 192, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 192, bitmap, Rect.new(0, 0, 240, 24), 60)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 192, bitmap, Rect.new(0, 0, (@actor.sp.to_f / @actor.maxsp.to_f) * 240, 24), 140)

      self.contents.draw_text(26, 192, contents.width, 24, "FP")

      self.contents.draw_text(70, 192, contents.width, 24, @actor.sp.to_s + "/" + @actor.maxsp.to_s)

    end

  end

end

And it's still not working! The status window appears blank, no matter which player the cursor is on. :pissed:
 
You aren't updating the status window...
Add this method:
Code:
class Window_Status

 

  def update(index)

    if @actor != index

      @actor = index

      refresh

    end

  end

end

Then change this line in Scene_Menu:
Code:
    @status_window.update
to this one:
Code:
    @status_window.update(@target_window.index)
 
Thanks for the help, Sheol! Your suggestion doesn't work as such, but it helped me to realize what was wrong and now the menu is working!! :biggrin:

Here are the working codes:

Menu:
Code:
#==============================================================================

# ** Scene_Menu

#------------------------------------------------------------------------------

#  This class performs menu screen processing.

#==============================================================================

 

class Scene_Inventory

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     menu_index : command cursor's initial position

  #--------------------------------------------------------------------------

  def initialize(menu_index = 0)

    @menu_index = menu_index

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    # Make command window

    s1 = $data_system.words.item

    s2 = $data_system.words.skill

    s3 = $data_system.words.equip

    @command_window = Window_Command.new(72 + 32, [s1, s2, s3])

    @command_window.index = @menu_index

    @command_window.back_opacity = 230

    # If number of party members is 0

    if $game_party.actors.size == 0

      # Disable items, skills, equipment, and status

      @command_window.disable_item(0)

      @command_window.disable_item(1)

      @command_window.disable_item(2)

    end

    # Make target window

    @target_window = Window_MenuTarget.new

    @target_window.x = 0

    @target_window.y = 160

    @target_window.opacity = 230

    # Make status window

    @status_window = Window_Status.new(@actor)

    @status_window.x = 72 + 32

    @status_window.y = 0

    @status_window.opacity = 230

    # Show map as background

    @spriteset = Spriteset_Map.new

    # 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

    @command_window.dispose

    @target_window.dispose

    @status_window.dispose

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Update windows

    @command_window.update

    @target_window.update

    # If command window is active: call update_command

    if @command_window.active

      update_command

      @status_window.contents.clear

      return

    end

    # If target window is active: call update_target

    if @target_window.active

      update_target

      @status_window.update(@target_window.index)

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (when command window is active)

  #--------------------------------------------------------------------------

  def update_command

    # If A button was pressed

    if Input.trigger?(Input::A)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to map screen

      $scene = Scene_Map.new

      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)

      # If command other than save or end game, and party members = 0

      if $game_party.actors.size == 0 and @command_window.index < 3

        # 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

        $scene = Scene_Item.new

      when 1  # skill

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Make target window active

        @command_window.active = false

        @target_window.active = true

        @target_window.index = 0

      when 2  # equipment

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Make target window active

        @command_window.active = false

        @target_window.active = true

        @target_window.index = 0

      end

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (when target window is active)

  #--------------------------------------------------------------------------

  def update_target

    # Get actor

    if Input.trigger?(Input::A)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Make command window active

      @command_window.active = true

      @target_window.active = false

      @target_window.index = -1

      return

    end

    # 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

      @target_window.active = false

      @target_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 1  # skill

        # If this actor's action limit is 2 or more

        if $game_party.actors[@target_window.index].restriction >= 2

          # Play buzzer SE

          $game_system.se_play($data_system.buzzer_se)

          return

        end

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to skill screen

        $scene = Scene_Skill.new(@target_window.index)

      when 2  # equipment

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to equipment screen

        $scene = Scene_Equip.new(@target_window.index)

      end

      return

    end

  end

end

 

Status Window:
Code:
# WINDOW_STATUS ================================================================

 

class Window_Status < Window_Base

 

  # Object Initialization ------------------------------------------------------

  #    actor : actor

  def initialize(actor)

    super(0, 0, 296, 480)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.opacity = 230

    @actor = actor

    refresh

  end

 

  # Update --------------------------------------------------------------------

  def update(index)

    if @actor != index

      @actor = $game_party.actors[index]

      refresh

    end

  end

 

  # Refresh --------------------------------------------------------------------

  def refresh

    self.contents.clear

    if @actor != -1 and @actor != nil

      self.contents.font.color = system_color

      self.contents.font.size = 20

      self.contents.draw_text(0, 0, contents.width, 24, @actor.name)

      self.contents.font.size = 18

      self.contents.draw_text(0, 24, contents.width, 24, "Faction:")

    # money_width = self.contents.text_size($game_party.gold.to_s).width

    # self.contents.draw_text(money_width + 4, 72, contents.width, 24, "$")

      self.contents.draw_text(26, 240, contents.width, 24, "ATK")

      self.contents.draw_text(26, 264, contents.width, 24, "ACC")

      self.contents.draw_text(26, 288, contents.width, 24, "CDEF")

      self.contents.draw_text(26, 312, contents.width, 24, "EDEF")

      self.contents.draw_text(26, 336, contents.width, 24, "STR")

      self.contents.draw_text(26, 360, contents.width, 24, "END")

      self.contents.draw_text(26, 384, contents.width, 24, "AGI")

      self.contents.draw_text(26, 408, contents.width, 24, "PER")

      # Draw values

      self.contents.font.color = normal_color

      self.contents.draw_text(72, 24, contents.width, 24, @actor.class_name)

      self.contents.draw_text(70, 240, contents.width, 24, @actor.atk.to_s)

      self.contents.draw_text(70, 264, contents.width, 24, @actor.hit.to_s)

      self.contents.draw_text(70, 288, contents.width, 24, @actor.pdef.to_s)

      self.contents.draw_text(70, 312, contents.width, 24, @actor.mdef.to_s)

      self.contents.draw_text(70, 336, contents.width, 24, @actor.str.to_s)

      self.contents.draw_text(70, 360, contents.width, 24, @actor.dex.to_s)

      self.contents.draw_text(70, 384, contents.width, 24, @actor.agi.to_s)

      self.contents.draw_text(70, 408, contents.width, 24, @actor.int.to_s)

      # Draw icons

      bitmap = RPG::Cache.icon("icon_symbol_attack")

      self.contents.blt(0, 240, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_accuracy")

      self.contents.blt(0, 264, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_cdef")

      self.contents.blt(0, 288, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_edef")

      self.contents.blt(0, 312, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_strength")

      self.contents.blt(0, 336, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_endura")

      self.contents.blt(0, 360, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_agility")

      self.contents.blt(0, 384, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.icon("icon_symbol_percept")

      self.contents.blt(0, 408, bitmap, Rect.new(0, 0, 24, 24), 200)

      # Draw condition icons

      if @actor.states.include?(1)

        bitmap = RPG::Cache.icon("icon_symbol_critical")

        self.contents.blt(0, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_critical_g")

        self.contents.blt(0, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(2)

        bitmap = RPG::Cache.icon("icon_symbol_blood")

        self.contents.blt(24, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_blood_g")

        self.contents.blt(24, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(3)

        bitmap = RPG::Cache.icon("icon_symbol_fire")

        self.contents.blt(48, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_fire_g")

        self.contents.blt(48, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(4)

        bitmap = RPG::Cache.icon("icon_symbol_hunger")

        self.contents.blt(72, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_hunger_g")

        self.contents.blt(72, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(5)

        bitmap = RPG::Cache.icon("icon_symbol_toxic")

        self.contents.blt(96, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_toxic_g")

        self.contents.blt(96, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(6)

        bitmap = RPG::Cache.icon("icon_symbol_bio")

        self.contents.blt(120, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_bio_g")

        self.contents.blt(120, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(7)

        bitmap = RPG::Cache.icon("icon_symbol_rad")

        self.contents.blt(144, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_rad_g")

        self.contents.blt(144, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      if @actor.states.include?(8)

        bitmap = RPG::Cache.icon("icon_symbol_psi")

        self.contents.blt(168, 72, bitmap, Rect.new(0, 0, 24, 24), 200)

      else

        bitmap = RPG::Cache.icon("icon_symbol_psi_g")

        self.contents.blt(168, 72, bitmap, Rect.new(0, 0, 24, 24), 60)

      end

      # Show level

      bitmap = RPG::Cache.icon("icon_symbol_level")

      self.contents.blt(0, 120, bitmap, Rect.new(0, 0, 24, 24), 200)

      self.contents.draw_text(26, 120, contents.width, 24, "L")

      self.contents.draw_text(70, 120, contents.width, 24, @actor.level.to_s)

      # Show exp bar

      bitmap = RPG::Cache.icon("icon_symbol_xp")

      self.contents.blt(0, 144, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 144, bitmap, Rect.new(0, 0, 240, 24), 60)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 144, bitmap, Rect.new(0, 0, (@actor.exp.to_f / @actor.next_exp.to_f) * 240, 24), 140)

      self.contents.draw_text(26, 144, contents.width, 24, "XP")

      self.contents.draw_text(70, 144, contents.width, 24, @actor.exp_s + "/" + @actor.next_exp.to_s)

      # Show hp bar

      bitmap = RPG::Cache.icon("icon_symbol_health")

      self.contents.blt(0, 168, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 168, bitmap, Rect.new(0, 0, 240, 24), 60)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 168, bitmap, Rect.new(0, 0, (@actor.hp.to_f / @actor.maxhp.to_f) * 240, 24), 140)

      self.contents.draw_text(26, 168, contents.width, 24, "HP")

      self.contents.draw_text(70, 168, contents.width, 24, @actor.hp.to_s + "/" + @actor.maxhp.to_s)

      # Show fp bar

      bitmap = RPG::Cache.icon("icon_symbol_fatigue")

      self.contents.blt(0, 192, bitmap, Rect.new(0, 0, 24, 24), 200)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 192, bitmap, Rect.new(0, 0, 240, 24), 60)

      bitmap = RPG::Cache.picture("icon_symbol_bar")

      self.contents.blt(24, 192, bitmap, Rect.new(0, 0, (@actor.sp.to_f / @actor.maxsp.to_f) * 240, 24), 140)

      self.contents.draw_text(26, 192, contents.width, 24, "FP")

      self.contents.draw_text(70, 192, contents.width, 24, @actor.sp.to_s + "/" + @actor.maxsp.to_s)

    end

  end

end
 

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