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.

Custom Selectable Window questions

Injury

Awesome Bro

Hey there, I'm hoping someone can help me with this.

I'm kinda making a custom job point system, and I gotta find out how I'd put a selectable item, then display a variable at the end of the column;determine weather or not the player has enough of variable x(job points), and if so, change the class upon enter/confirm. I'd really like to make little icons for the jobs too, but I don't know how to do that either, so maybe someone can be nice and help me out, and explain it in detail to me, so it HAS to go through my head.

Thanks!

I need to know the following.
-How to call a script
-How to call this script from the menu.
-While in the window for this, be able to select a Job Class, view it, and have a choice to change to said class.
-Control to enable and disable class changing. I'm making it so the character has to go to an NPC to get a job change, but they can view the jobs available to them, based on their levels.
Code:
class Window_Selectable < Window_Base
# ------------------------------------
attr_reader   :index
attr_reader   :help_window
# ------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @item_max = 1
    @column_max = 1
    @index = -1
  end
# ------------------------------------
  def index=(index)
    @index = index
    if self.active and @help_window != nil
      update_help
    end
    update_cursor_rect
  end
# ------------------------------------
  def row_max
    return (@item_max + @column_max - 1) / @column_max
  end
# ------------------------------------
  def top_row
    return self.oy / 32
  end
# ------------------------------------
  def top_row=(row)
    if row < 0
      row = 0
    end
    if row > row_max - 1
      row = row_max - 1
    end
    self.oy = row * 32
  end
# ------------------------------------
  def page_row_max
    return (self.height - 32) / 32
  end
# ------------------------------------ 
  def page_item_max
    return page_row_max * @column_max
  end
# ------------------------------------
  def help_window=(help_window)
    @help_window = help_window
    if self.active and @help_window != nil
      update_help
    end
  end
# ------------------------------------ 
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    if row < self.top_row
      self.top_row = row
    end
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    cursor_width = self.width / @column_max - 32
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    self.cursor_rect.set(x, y, cursor_width, 32)
  end
# ------------------------------------
  def update
    super
    if self.active and @item_max > 0 and @index >= 0
      if Input.repeat?(Input::DOWN)
           if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
           @index < @item_max - @column_max
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
        end
      end
      if Input.repeat?(Input::UP)
          if (@column_max == 1 and Input.trigger?(Input::UP)) or
           @index >= @column_max
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
        end
      end
      if Input.repeat?(Input::RIGHT)
        if @column_max >= 2 and @index < @item_max - 1
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      if Input.repeat?(Input::LEFT)
        if @column_max >= 2 and @index > 0
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      if Input.repeat?(Input::R)
        if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
          $game_system.se_play($data_system.cursor_se)
          @index = [@index + self.page_item_max, @item_max - 1].min
          self.top_row += self.page_row_max
        end
      end
      if Input.repeat?(Input::L)
        if self.top_row > 0
          $game_system.se_play($data_system.cursor_se)
          @index = [@index - self.page_item_max, 0].max
          self.top_row -= self.page_row_max
        end
      end
    end
    if self.active and @help_window != nil
      update_help
    end
    update_cursor_rect
  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