Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,356
Reaction score
795
First Language
English
Primarily Uses
RMVXA
Use Command / Details Window v1.03
by Roninator2​

Introduction
A script to give a use command before using items. Also offers a discard command and details command to view information about the item.

Features
- Gives information window for viewing item details - Crazyninjaguy
- Gives discard command to throw away items
- Gives use command for items
- Fixed issue for yanfly item menu compatibility (X2 - another small issue)
- Added option to disable commands. Read options in script

How to Use
Put below ▼ Materials

Images
1633346289698.png1633345877502.png
1633346447937.png1633346323463.png

Script
Ruby:
#===============================================================================
# * SEE - Item Menu ACE
# * By Crazyninjaguy
# * Requested by BizarreMonkey
# * Modified by Roniunator2
# * http://www.stormxstudios.co.uk
# * 11/11/2021 - V1.03
# * If you like my scripts, please show your appreciation by checking out
#   my friendly, helpful Game Development Community, StormCross Studios.
#  ---------------------------------------------------------------------------
# * Aliased Methods
#    - start (Scene_Item)
#    - update_item_selection (Scene_Item)
#    - terminate (Scene_Item)
#  ---------------------------------------------------------------------------
# * This script adds a new item description window with support for four text
#   text lines and a 96 x 96 picture in Graphics/Pictures.
# * To add a picture for your item, add this into the notebox of that item in
#   the database
# * <picture potionpicture>
# * Replacing potionpicture for your image filename.
#===============================================================================

#===============================================================================
# !!!!!!!If using Yanfly Item Menu, it must be placed above this script.!!!!!!!
#===============================================================================

$imported = {} if $imported == nil
$imported["SEE - Item Menu Ace"] = true

#===============================================================================
# * Main StormCross Engine Evolution Configuration Module
#===============================================================================
module SEE
 #=============================================================================
 # * Item Menu Configuration Module
 #=============================================================================
  module Item
  ITEMS = []
#===========================================================================
# * The number at the beginning of the ITEMS[1] is the item id in the
#   database.
# * Each line of text in quotes is a seperate line in the window.
#   Seperate each with a comma
#===========================================================================
  ITEMS[1] = ["This is a potion.", "It's very nice and restores 500hp.", "Costs 50 Gil in a shop.", "Has a purplish glow."]
  ITEMS[2] = ["This is a high potion.", "It's very nice and restores 2500hp.", "Costs 150 Gil in a shop.", "Has a purplish glow."]

  WEAPONS = []
  WEAPONS[1] = ["Derp", "", "", ""]

  ARMORS = []
  ARMORS[1] = ["", "", "", ""]

  ITEM_COLOURS = []
#===========================================================================
# * As with the previous, the number at the beginning of COLOURS[1] is the
#   item id in the database.
# * The numbers in the array correspond to the text_color() argument of
#   window base. 0 is white. You can find these by looking at the
#   Window.png graphic. Seperate each value with a comma.
#===========================================================================
  ITEM_COLOURS[1] = [0, 1, 2, 3]

  WEAPON_COLOURS = []
  WEAPON_COLOURS[1] = [0, 1, 2, 3]

  ARMOR_COLOURS = []
  ARMOR_COLOURS[1] = [0, 1, 2, 3]
 
  # Show Commands
  Use       = true
  Discard   = true
  Details   = true
  Cancel    = true
 
  end # Item
end # SEE

module ReadNote
  def read_note(note, tag, position = 1)
    note2 = note.dup
    lines = note2.scan(/<.+>/)
    for line in lines
      words = line.split(/[ <>]/)
      words.delete("")
      for word in words
        if word == tag
          result = words[words.index(word) + position]
          return true if result == nil
          return result
        end
      end
    end
    return false
  end
end

#==============================================================================
# ** Window_SubItemCategory
#------------------------------------------------------------------------------
#  This window is for selecting a category of normal items and equipment
# on the item screen or shop screen.
#==============================================================================

class Window_SubItemCategory < Window_Command
  attr_reader :item_window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y)
    @category = :none
    self.back_opacity = 255
    clear_command_list
    make_command_list
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 120
  end
  #--------------------------------------------------------------------------
  # * Get Window Height
  #--------------------------------------------------------------------------
  def window_height
    fitting_height(visible_line_number)
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_command("Use", :use, @category == :item) if SEE::Item::Use == true
    add_command("Discard", :discard) if SEE::Item::Discard == true
    add_command("Details", :details) if SEE::Item::Details == true
    add_command("Cancel", :cancel) if SEE::Item::Cancel == true
  end
  def category=(category)
    return if @category == category
    @category = category
    refresh
  end
  def category(category)
    @category = category
    refresh
  end
  def update
    super
    @category = @item_window.current_symbol if @subitem_window
  end
end


class Scene_Item < Scene_ItemBase
  attr_accessor :item_window
  alias r2_start_item_for_yanfly    start
  def start
    r2_start_item_for_yanfly
    create_description_window
    create_sub_item_window
    create_number_window
    @description_index = 0
  end
  def create_description_window
    @description = Window_ItemDescription.new
    @description.hide
    @description.viewport = @viewport
    @description.set_handler(:cancel, method(:details_cancel))
  end
  def create_item_window
    wy = @category_window.y + @category_window.height
    wh = Graphics.height - wy
    @item_window = Window_ItemList.new(0, wy, Graphics.width, wh)
    @item_window.help_window = @help_window
    @item_window.set_handler(:ok,     method(:on_sub_item_ok))
    @item_window.set_handler(:cancel, method(:on_item_cancel))
    @category_window.item_window = @item_window
    @item_window.viewport = @viewport
  end
  def create_sub_item_window
    wy = @category_window.y + @category_window.height
    @subitem_window = Window_SubItemCategory.new(200, wy + 50)
    @subitem_window.set_handler(:use,     method(:on_item_ok))
    @subitem_window.set_handler(:discard,     method(:on_item_discard))
    @subitem_window.set_handler(:details,     method(:on_item_details))
    @subitem_window.set_handler(:cancel, method(:on_sub_item_cancel))
    @category_window.item_window = @item_window
    @subitem_window.viewport = @viewport
    @subitem_window.hide
  end
  def create_number_window
    wy = @category_window.y + @category_window.height
    wh = 48
    @number_window = Window_DiscardNumber.new(100, wy + 50, wh)
    @number_window.viewport = @viewport
    @number_window.hide
    @number_window.set_handler(:ok,     method(:on_number_ok))
    @number_window.set_handler(:cancel, method(:on_number_cancel))
  end
  def activate_item_window
    @item_window.refresh
    @subitem_window.refresh
    @subitem_window.activate
  end
  def on_item_discard
    @subitem_window.deactivate
    @subitem_window.hide
    @number_window.set(item, $game_party.item_number(item))
    @number_window.activate
    @number_window.show
  end
  if $imported["YEA-ItemMenu"] == true
    def open_types
      @category_window.x = Graphics.width
      @types_window.x = 0
      @types_window.reveal(@category_window.current_symbol)
      @subitem_window.category(@category_window.current_symbol)
    end
  end
  alias r2_item_nil_count on_item_ok
  def on_item_ok
    if item == nil
      Sound.play_buzzer
      on_sub_item_cancel
      return
    end
    r2_item_nil_count
  end
  def on_sub_item_ok
    if @item_window.item == nil
      Sound.play_buzzer
      on_sub_item_cancel
    else
      @category_window.item_window = @subitem_window
      @subitem_window.activate
      @subitem_window.select(0)
      @subitem_window.show
      @item_window.deactivate
    end
  end
  def on_item_details
    @description.show
    @description.activate
    @description.z = 1000
    @subitem_window.deactivate
    @subitem_window.hide
    @item_window.deactivate
    update
  end
  def on_sub_item_cancel
    @subitem_window.deactivate
    @subitem_window.hide
    @item_window.activate
    @category_window.item_window = @item_window
  end
  def details_cancel
    @description.deactivate
    @description.hide
    @subitem_window.activate
    @subitem_window.show
    @subitem_window.select(0)
  end
  def on_number_ok
    discard(@number_window.number)
    play_se_for_item
    @number_window.hide
    @item_window.refresh
    on_sub_item_cancel
  end
  def discard(number)
    $game_party.lose_item(item, number)
  end
  def on_number_cancel
    Sound.play_cancel
    @number_window.hide
    on_sub_item_cancel
  end
  def update
    super
    if @description_index != @item_window.index
      @description.details(@item_window.item)
      @description_index = @item_window.index
    end
  end
end

class Window_ItemList < Window_Selectable
  def enable?(item)
    return true
  end
end

class Window_ItemDescription < Window_Selectable
  include ReadNote
  include SEE::Item
  def initialize(item = nil)
    super(0, 0, window_width, window_height)
    self.back_opacity = 255
    details(item)
  end # initialize
  def window_width
    Graphics.width
  end
  def window_height
    Graphics.height
  end
  def details(item)
    self.contents.clear
    if item != nil
      if item.is_a?(RPG::Item)
        picture = read_note($data_items[item.id].note, "picture")
      elsif item.is_a?(RPG::Weapon)
        picture = read_note($data_weapons[item.id].note, "picture")
      elsif item.is_a?(RPG::Armor)
        picture = read_note($data_armors[item.id].note, "picture")
      end
      if picture != false
        bitmap = Cache.picture(picture)
        rect = Rect.new(0, 0, 96, 96)
        self.contents.blt(0, 0, bitmap, rect)
      end
      if item.is_a?(RPG::Item)
        if ITEMS[item.id] != nil
          if ITEM_COLOURS[item.id] != nil
            self.contents.font.color = text_color(ITEM_COLOURS[item.id][0])
            self.contents.draw_text(96, 0, width - 128, 24, ITEMS[item.id][0])
            self.contents.font.color = text_color(ITEM_COLOURS[item.id][1])
            self.contents.draw_text(96, 24, width - 128, 24, ITEMS[item.id][1])
            self.contents.font.color = text_color(ITEM_COLOURS[item.id][2])
            self.contents.draw_text(96, 48, width - 128, 24, ITEMS[item.id][2])
            self.contents.font.color = text_color(ITEM_COLOURS[item.id][3])
            self.contents.draw_text(96, 72, width - 128, 24, ITEMS[item.id][3])
            self.contents.font.color = text_color(0)
          else
            self.contents.draw_text(96, 0, width - 128, 24, ITEMS[item.id][0])
            self.contents.draw_text(96, 24, width - 128, 24, ITEMS[item.id][1])
            self.contents.draw_text(96, 48, width - 128, 24, ITEMS[item.id][2])
            self.contents.draw_text(96, 72, width - 128, 24, ITEMS[item.id][3])
          end
        end
      elsif item.is_a?(RPG::Weapon)
        if WEAPONS[item.id] != nil
          if WEAPON_COLOURS[item.id] != nil
            self.contents.font.color = text_color(WEAPON_COLOURS[item.id][0])
            self.contents.draw_text(96, 0, width - 128, 24, WEAPONS[item.id][0])
            self.contents.font.color = text_color(WEAPON_COLOURS[item.id][1])
            self.contents.draw_text(96, 24, width - 128, 24, WEAPONS[item.id][1])
            self.contents.font.color = text_color(WEAPON_COLOURS[item.id][2])
            self.contents.draw_text(96, 48, width - 128, 24, WEAPONS[item.id][2])
            self.contents.font.color = text_color(WEAPON_COLOURS[item.id][3])
            self.contents.draw_text(96, 72, width - 128, 24, WEAPONS[item.id][3])
            self.contents.font.color = text_color(0)
          else
            self.contents.draw_text(96, 0, width - 128, 24, WEAPONS[item.id][0])
            self.contents.draw_text(96, 24, width - 128, 24, WEAPONS[item.id][1])
            self.contents.draw_text(96, 48, width - 128, 24, WEAPONS[item.id][2])
            self.contents.draw_text(96, 72, width - 128, 24, WEAPONS[item.id][3])
          end
        end
      elsif item.is_a?(RPG::Armor)
        if ARMORS[item.id] != nil
          if ARMOR_COLOURS[item.id] != nil
            self.contents.font.color = text_color(ARMOR_COLOURS[item.id][0])
            self.contents.draw_text(96, 0, width - 128, 24, ARMORS[item.id][0])
            self.contents.font.color = text_color(ARMOR_COLOURS[item.id][1])
            self.contents.draw_text(96, 24, width - 128, 24, ARMORS[item.id][1])
            self.contents.font.color = text_color(ARMOR_COLOURS[item.id][2])
            self.contents.draw_text(96, 48, width - 128, 24, ARMORS[item.id][2])
            self.contents.font.color = text_color(ARMOR_COLOURS[item.id][3])
            self.contents.draw_text(96, 72, width - 128, 24, ARMORS[item.id][3])
            self.contents.font.color = text_color(0)
          else
            self.contents.draw_text(96, 0, width - 128, 24, ARMORS[item.id][0])
            self.contents.draw_text(96, 24, width - 128, 24, ARMORS[item.id][1])
            self.contents.draw_text(96, 48, width - 128, 24, ARMORS[item.id][2])
            self.contents.draw_text(96, 72, width - 128, 24, ARMORS[item.id][3])
          end
        end
      end
    end
  end # refresh
end # Window_ItemDescription

#==============================================================================
# ** Window_DiscardNumber
#------------------------------------------------------------------------------
#  This window is for inputting quantity of items to buy or sell on the shop
# screen.
#==============================================================================

class Window_DiscardNumber < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :number                   # quantity entered
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, height)
    super(x, y, window_width, height)
    @item = nil
    @max = 1
    @number = 1
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 304
  end
  #--------------------------------------------------------------------------
  # * Set Item, Max Quantity, Price, and Currency Unit
  #--------------------------------------------------------------------------
  def set(item, max)
    @item = item
    @max = max
    @number = 1
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_item_name(@item, 0, 0)
    draw_number
  end
  #--------------------------------------------------------------------------
  # * Draw Quantity
  #--------------------------------------------------------------------------
  def draw_number
    change_color(normal_color)
    draw_text(cursor_x - 28, 0, 22, line_height, "×")
    draw_text(cursor_x, 0, cursor_width - 4, line_height, @number, 2)
  end
  #--------------------------------------------------------------------------
  # * Get Cursor Width
  #--------------------------------------------------------------------------
  def cursor_width
    figures * 10 + 12
  end
  #--------------------------------------------------------------------------
  # * Get X Coordinate of Cursor
  #--------------------------------------------------------------------------
  def cursor_x
    contents_width - cursor_width - 4
  end
  #--------------------------------------------------------------------------
  # * Get Maximum Number of Digits for Quantity Display
  #--------------------------------------------------------------------------
  def figures
    return 2
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if active
      last_number = @number
      update_number
      if @number != last_number
        Sound.play_cursor
        refresh
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Quantity
  #--------------------------------------------------------------------------
  def update_number
    change_number(1)   if Input.repeat?(:RIGHT)
    change_number(-1)  if Input.repeat?(:LEFT)
    change_number(10)  if Input.repeat?(:UP)
    change_number(-10) if Input.repeat?(:DOWN)
  end
  #--------------------------------------------------------------------------
  # * Change Quantity
  #--------------------------------------------------------------------------
  def change_number(amount)
    @number = [[@number + amount, @max].min, 1].max
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def update_cursor
    cursor_rect.set(cursor_x, 0, cursor_width, line_height)
  end
end


Credit and Thanks
- Roninator2
- Crazyninjaguy - for original code with description window


Terms of use
Free for all RPG Maker VX Ace uses
 
Last edited:

Szibes

Villager
Member
Joined
Mar 5, 2021
Messages
19
Reaction score
3
First Language
Polish
Primarily Uses
RMVXA
There's an incompatibility issue with Yanfly's Item Menu

line 1136: NoMethodError occurred.
undefined method 'x=' for nil:Nilclass
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,356
Reaction score
795
First Language
English
Primarily Uses
RMVXA
incompatibility issue
Yanfly's Ace Item Menu has to be below this script.
Yanfly aliases the scene_item. This script overwrites.
I could look into changing that so there would not be a problem if this script was placed below.
*update. done. Changed start to an alias and it's good now.
 

Szibes

Villager
Member
Joined
Mar 5, 2021
Messages
19
Reaction score
3
First Language
Polish
Primarily Uses
RMVXA
That was fast.
Thank you.
 

elann

Warper
Member
Joined
Oct 15, 2021
Messages
3
Reaction score
0
First Language
English
Primarily Uses
Other
Thanks mate.
 

Szibes

Villager
Member
Joined
Mar 5, 2021
Messages
19
Reaction score
3
First Language
Polish
Primarily Uses
RMVXA
I only noticed it now, but I think this script is still incompatible with Yanfly's one.

The "use" command is always sealed, it only works when I disable Yanfly's item menu. From what I understand both script overwrite the same sections in many places, so it's probably not something that can be fixed easily.

Also, is it possible to have this script version with only "use" and "details"
or just "details" that can be shown by pressing a key (now, that's something that I'm sure isn't easy to get done, so I'm not really expecting to get it), if incompatibility is outside these functions (though it's probably in these functions) then it would fix that problem, at least for me.

Or is there's a script that allows for better item categorization that is compatible with this one.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,356
Reaction score
795
First Language
English
Primarily Uses
RMVXA
still incompatible with Yanfly's one
Sorry, yanfly changes the item scene. I just had to figure out how to get the window to know it is items you are looking at.
Should work fine now.
 

Szibes

Villager
Member
Joined
Mar 5, 2021
Messages
19
Reaction score
3
First Language
Polish
Primarily Uses
RMVXA
The "use" command is still sealed, even after placing it above Yanfly's core.
I guess these two are just incompatible, so there's no real point in trying to solve this.
I really have to start playtesting the hell out of new scripts,
instead of accidentally discovering bugs a week later while testing something else.

I mainly wanted to use this script for showing things like parameters, special effects, etcetera,
because the previous script that I used for that had a MINOR visual bug, but now I think it would be just better to try to fix that.

Thank you for your work and time anyway.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,356
Reaction score
795
First Language
English
Primarily Uses
RMVXA
even after placing it above Yanfly's core.
This script has to go below yanfly's scripts.
You can send me you script file and I'll confirm, if you want.
 

Szibes

Villager
Member
Joined
Mar 5, 2021
Messages
19
Reaction score
3
First Language
Polish
Primarily Uses
RMVXA
Who's a lobotomized lobster that can't read? Me.
Thanks, now it works.
 

Latest Threads

Latest Posts

Latest Profile Posts

Question for the Mods: What am I supposed to do when I can't make a synopsis 350 words long? (for project recruitment thread) @Shaz @mlogan
The game is meant to be more on the simple side in order to be achievable so I'm a bit stuck...
Had a nice visit with our family. Dad grilled some burgers and mom made baked beans and fudge. We also watched Foul Play. Chevy Chase and Goldie Hawn make an awesome duo. I am surprised how much of the movie I forgot LOL. How did everyone else's holidays go?
Got a windowskin working nicely to go with Mog's menu plugins.
p8BE5bj.png

tsD4gZS.png

nwpeK84.png
Just getting started on RPG maker and having a blast!
I am once again escalating in the kitchen. I might or might not be 4 types of cookies into baking and not finished...

Forum statistics

Threads
117,039
Messages
1,104,032
Members
152,970
Latest member
mrne
Top