Status
Not open for further replies.

whotfisjojo

clownin' around
Veteran
Joined
Jun 5, 2019
Messages
78
Reaction score
26
First Language
English
Primarily Uses
RMVXA
i never liked being able to open the items menu when i had no items in games it felt very tedious and annoying.... i specifically remember being confused the first time i played an rpgmaker game why i had to select the items menu INSIDE of the items menu
so i found a script that just shows it right away but for some reason when you select the empty item slot it crashes the game anyways
so i figure that just makes it even more important to find a way to disable/gray out the item menu (like the continue option when you dont have a save file) when the inventory is empty (maybe even a way to close the item menu immediately after using the last item to decrease the risk of pressing an empty slot?)

not sure if you can do it with events, switches, common events, or just a script but heres my menu scripts anyways in case its a "menu specific" kind of thing:
Ruby:
module Zale
  module KsiMenu
    Window_Skin = "" # if this is not empty, it will set the windowskin to this.
    line_height = 24 #24 is the default
    Face_WP = 2# Add additional padding here
    Face_HP = 2
    Win_W = 96 * 3 + 20 + (Face_WP * 3)
    Win_H = 75 * 2 + 24 + Face_HP
    Pos_X = Graphics.width / 2 - (Win_W / 2) # Center it on screen
    Pos_Y = Graphics.height * 0.1
    Face_W = 96
    Face_H = 96
 
    Arrows = true  # Show arrows on the help window? (they're there because we shrunk the window
                   # And it thinks that something is there).
  end
end

class Window_MenuHCommand < Window_HorzCommand
  # We include Zale::KsiMenu in ever class because it's faster
  # to write out 'Variable' rather than 'Zale::KsiMenu::Variable' for everything
  include Zale::KsiMenu
 
  # Initialize is called whenever any object is make. It's built into ruby to do
  # that, so this is where you would put everything to set up what you're making.
  # In this case, we call this window's superclass, which we see above is
  # Window_HorzCommand (Horizontal command window). It needs to know where to place
  # the window, so we use the variables x and y, which we got when the object was
  # originally made.
  # Then we check if the Window_Skin variable is "" (empty). If it is, don't do
  # anything. If it is different though, use that as our window skin. Then we
  #use self.width = blah to change how wide the window is. We want all the windows
  # to be the same width, so we use the same variable (Technically, variables that
  # start with capital letters are constants, we're not allowed to change them,
  # though there is *technically* a way to).
  # Next we call the refresh method, and then update the cursor.
  #
  # The refresh method is not in this class, so where is it? Kind of like when we
  # called super in initialize, if we don't define a method in out class, and then
  # some other script calls this method (such as refresh), we see if the superclass
  # has it. If it does, we do that, if not, check its superclass. This keeps going
  # until we find the method or we run out of classes, in which case we'll get an
  # error saying we can't find this method.
  # These types of errors are 'undefined local variable or method `something' for
  # MyClass:0xItsMemoryAddress.
  def initialize(x, y)
    super(x, y)
    if Zale::KsiMenu::Window_Skin != ""
      self.windowskin = Cache.system(Window_Skin)
    end
    self.width = Win_W
    refresh
    update_cursor
  end
 
  # We use the add_command method, defined in Window_Command to add a command to the
  # window so we can select it later. We give it a symbol, the thing with the : in front
  # so that we can handle that specifically later. Vocab.whatever is the set of terms that
  # are defined in the Terms tab of the database. You can see the available terms at the
  # Vocab script at the top of the script editor. Check the bottom for the ones you can use
  # They'll look like:
  # def self.item;        command(4);   end   # Items
  def make_command_list
    add_command(Vocab.item,     :item)
    add_command("LOAD", :load, load_possible)
    add_command(Vocab.shutdown, :quit)
  end
 
    def load_possible
    DataManager.save_file_exists?
  end
 
  # Here we define how many columns out window will have. By default, a Window_HorzCommand
  # window will have four columns, but we only want 3, item, save, and quit. So this is how
  # we set that up.
  def col_max
    return 3
  end
end

class Window_KsiStatus < Window_Selectable
  include Zale::KsiMenu
 
  # Same as above.
  # @index = -1 is used to make sure we don't have a cursor over any
  # of the actor's faces (even though it shouldn't be there anyway).
  def initialize
    super(Pos_X, Pos_Y, Win_W, Win_H)
    if Window_Skin != ""
      self.windowskin = Cache.system(Window_Skin)
    end
    @index = -1
    draw_actors
  end
 
  # Here's an example of a refresh method. This will clear the contents
  # of a window, which is just a bitmap, a picture. It's refered to by
  # a method named 'contents'. So we clear it using contents.clear, and
  # then we use the create_contents method which will make a new bitmap
  # to use. This will make it whatever size we need and make sure it's
  # cleared. Then we redraw the actor's faces.
  def refresh
    contents.clear
    create_contents
    draw_actors
  end
 
  # First we setup variables for position, since we'll be changing them
  # based on how many faces we've already drawn. Then, for the size of
  # our party, we go through all the people. 'i' starts at 0 whenever you
  # use the 'times' method, and it increases by one each time the loop end
  # until it has done the number of loops. So we want to see, if i is greater
  # than 5(it drew 6 faces), then we just skip to the next iteration by using
  # 'next' This will keep happening until we run out of actors. We do this
  # because we won't fit them onto the screen anyway, so don't waste the time
  # to draw them.
  def draw_actors
    x = y = 0
    $game_party.members.size.times{ |i|
      if i > 5
        next # index starts at 0, greater than 5 won't be drawn on the screen unless you change the dimensions.
      end
  def draw_current_and_max_values(x, y, width, current, max, color1, _color2)
    change_color(color1)
    xr = x + width
    percentage = max.nonzero? ? (current.fdiv(max) * 100).ceil : 0
    draw_text(xr - 40, y, 42, line_height,"#{percentage}%", 2)
  end
      act = $game_party.members[i]
      draw_face(act.face_name, act.face_index, x, 13)
      draw_actor_name(act, x, y-6, width = 112)
      draw_actor_hp(act, x, y+103, width = 95)
      draw_actor_mp(act, x, y+122, width = 95)
      x += Face_W + Face_WP
      if x >= Face_W * 3 + (Face_WP * 3)
        x = 0
        y += Face_H + Face_HP
      end
    }
  end
end

class Scene_Menu < Scene_MenuBase
  include Zale::KsiMenu
  def start
    super
    create_status
    create_command
  end
 
  # Create the window that we use to select our commands. This is where
  # we use those symbols to handle processing separately. First, though,
  # we make the command window with the x position, and the y position
  # PLUS the height of the status window, because we want the command
  # window to be on the bottom of the status window.
 
  # Then we use the set_handler command for window so we can tell
  # Ruby what to do when we select an option. We need to specify the
  # symbol we gave them when we added the commands, and then a method
  # to handle the option. the method() command is part of Ruby's kernel
  # which will give you a way to call a method from anyway. We can pass
  # the method around from class to class, and still use it. So in this
  # case we're putting the method 'command_item' into another class,
  # because that's where its held until we select the option. They're
  # all stored in Window_Command. It has a container (A simple Hash)
  # to hold them all.
  def create_command
    @cmd = Window_MenuHCommand.new(Pos_X, Pos_Y + @stat.height)
    @cmd.set_handler(:item, method(:command_item))
    @cmd.set_handler(:load, method(:command_load))
    @cmd.set_handler(:quit, method(:command_quit))
  end
 
  # Create the status menu, which sets itself up automatically, we don't
  # need to pass any values to its initialize method for it to finish
  # properly.
  def create_status
    @stat = Window_KsiStatus.new
  end
 
  # The SceneManager is what handles all the scenes in the game. As such,
  # that's how we change them too. The command_whatever methods just change
  # the scene.
  def command_item
    SceneManager.call(Scene_Items)
  end
 
  def command_load
    SceneManager.call(Scene_Load)
  end
 
  def command_quit
    SceneManager.call(Scene_End)
  end
 
  # Update is called by Scene_Base every frame. In this scene, we're going
  # to run Scene_Base's update so that the game doesn't crash, and then we
  # check to see if we press the :B key, which is the escape key by default.
  # If we do press it, we return to the scene that was up before this.
  def update
    super
    if Input.trigger?(:B)
      SceneManager.return
    end
  end
 
  # When the scene is being closed, we need to clean up, so we dispose our
  # windows so that we can free up the memory they used.
  def terminate
    super
    @stat.dispose
    @cmd.dispose
  end
 
end

class Window_KsiItem < Window_Selectable
  # This class is mostly recycled from the Window_ItemList class, as it mainly still all
  # applied, I just took out the category window. The attr_accessor is saying to let
  # a class that has a KsiItem window to change or see what we have for our @help_window
  # variable. We use this to give it the window under the item list in the item scene
  # so that it can update the description.
  attr_accessor :help_window
  include Zale::KsiMenu
  def initialize
    @items = []
    super(Pos_X, Pos_Y, Win_W, Win_H)
    refresh
    select(0)
    activate
  end
 
  def make_item_list
    @items = $game_party.all_items
    @items.empty? ? @items.push(nil) : nil
  end
 
  def col_max
    return 1
  end
 
  def enable?(item)
    $game_party.usable?(item)
  end
 
  def draw_item(index)
    item = @items[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y, enable?(item), rect.width - 24)
      draw_item_number(rect, item)
    end
  end
 
  def draw_item_number(rect, item)
     draw_text(rect, sprintf("x%2d", $game_party.item_number(item)), 2)
  end
 
  def item
    @items && index >= 0 ? @items[index] : nil
  end
 
  def update_help
    @help_window.set_item(item)
  end
 
  def cursor_move
    super
    update_help
  end
 
  def item_max
    return @items.size
  end
 
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
end

class Scene_Items < Scene_ItemBase
  # The Item scene class. In the initialize method, we setup the help window
  # that displays the item's description, as well as create the item window.
  include Zale::KsiMenu
  def start
    super
    create_help_window
    create_item
    @actor_window.hide
    @help_window.x = Pos_X
    @help_window.y = Pos_Y + Win_H
    @help_window.height = @help_window.fitting_height(1)
    @help_window.width = Win_W
    @help_window.arrows_visible = Arrows
    if Window_Skin != ""
      @help_window.windoskin = Cache.system(Window_Skin)
      @item_window.windowskin = Cache.system(Window_Skin)
    end
  end
 
  # We create the item window, set its help window using the attr_accessor we made
  # earlier, and then update the help window so that the description is updated and
  # ready when the scene starts.
  def create_item
    @item_window = Window_KsiItem.new
    @item_window.help_window = @help_window
    @item_window.update_help
  end
 
  # Check to see if we want to leave the item scene!
  def update
    super
    if Input.trigger?(:B)
      SceneManager.return
    end
  end

  # Clean up our item window. The help window was made by the superclass, so we
  # letit take care of that.
  def terminate
    super
    @item_window.dispose
  end
end
Ruby:
# ==============================================================================
# Edit by: vFoggy
# Adds item usage functionality to the KsiMenu script. Also added some sounds on
# closing windows.
# ==============================================================================
class Scene_Menu < Scene_MenuBase
  def update
    super
    if Input.trigger?(:B)
      SceneManager.return
      # Edit: Added sound on going to the previous menu
      Sound.play_cancel
    end
  end
end

class Scene_Items < Scene_ItemBase
  # Edit: Added create_item method
  def create_item
    @item_window = Window_KsiItem.new
    @item_window.help_window = @help_window
    @item_window.update_help
    @item_window.set_handler(:ok, method(:on_item_ok))
  end
 
  # Edit: Added on_item_ok method
  def on_item_ok
    $game_party.last_item.object = item
    determine_item
  end
 
  # Edit: Added show_sub_window method.
  def show_sub_window(window)
    width_remain = Graphics.width - window.width
 
    # Edit: Changed the position of the actor menu window
    offset = ((@item_window.width - @actor_window.width).abs/2).to_i
    window.x = @item_window.x - offset
    window.y = 0
    window.z = 1000
 
    @viewport.rect.x = @viewport.ox = cursor_left? ? 0 : window.width
    @viewport.rect.width = width_remain
    window.show.activate
  end
 
  def update
    super
    if Input.trigger?(:B)
      SceneManager.return
      # Edit: Added sound on going to the previous menu
      Sound.play_cancel
    end
  end
 
  # Edit: play_se_for_item
  def play_se_for_item
    Sound.play_use_item
  end
 
  # Edit: Added use_item method
  def use_item
    super
    @item_window.redraw_current_item
  end
end
please let me know if you can help! id really appreciate it! thanks!
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,282
Reaction score
755
First Language
English
Primarily Uses
RMVXA
Two options. I'm guessing the second is what you want.
One fix the crash when selecting a nil item.
Ruby:
class Scene_Items < Scene_ItemBase
  def on_item_ok
    if item.nil?
      @item_window.activate
      return
    end
    $game_party.last_item.object = item
    determine_item
  end
end

Two stop access to the item scene
Ruby:
class Window_MenuHCommand < Window_HorzCommand
  def make_command_list
    add_command(Vocab.item,     :item, !$game_party.all_items.empty?)
    add_command("LOAD", :load, load_possible)
    add_command(Vocab.shutdown, :quit)
  end
end
 

whotfisjojo

clownin' around
Veteran
Joined
Jun 5, 2019
Messages
78
Reaction score
26
First Language
English
Primarily Uses
RMVXA
ahhhh!!! you are my savior roninator!!! this is so great!!! i am so happy ive been waiting for a menu like this for so long- you have no idea how much this means!! thank you thank you thank you!!! :wub
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,653
Reaction score
15,285
First Language
English
Primarily Uses
RMMV

I've moved this thread to RGSSx Script Support. Thank you.



This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

I have a really hard time keeping all these goodies secret til December... but I swear, it is worth the wait!
Working on a Premium version of my minimap plugin that will have advanced functionalities such as drawing a Terrain map based completely on the users tilesets, whatever they may be, and drawing minimap radar icons automatically based on texture of the event the note is applied to.
Psttt come look, this is the secret technique to tenderizing steaks, it makes it extra beefy. :rwink:

pixeldailyaxemeatsheild.gif
#screenshotsaturday update, featuring vaporwave angels lol

Forum statistics

Threads
115,853
Messages
1,093,472
Members
151,065
Latest member
NODIE_2389948289021842323
Top