SpuddyGoggles 0 Posted April 9 The more I attempt to tamper with Ruby, the more I understand that I'm very very dumb. I have managed to get by enough to make a menu that fits my liking, along with an inventory that is also satisfactory. However I've hit a snag with one of the more vital options of my pause menu... The equip menu! Despite my ceaseless trial and error, I have found myself stumped due to nothing but my own incompetence. As such, I now find myself calling upon the help of those more adept at Ruby than I am. Below is the current pause menu. And this is a mockup of what I want the equip menu to look like. I know that I'm probably asking for a lot, but even some help would be appreciated. Share this post Link to post Share on other sites
roninator2 257 Posted April 9 Is this for a single actor menu? You will only ever have one actor in the party? Share this post Link to post Share on other sites
SpuddyGoggles 0 Posted April 9 30 minutes ago, roninator2 said: Is this for a single actor menu? You will only ever have one actor in the party? Yes, there is only going to be one actor in the party. Share this post Link to post Share on other sites
roninator2 257 Posted April 9 How many equipment slots will you have? 0 - weapon 1 - shield 2 - helmet 3 - armor 4 - accessory etc Share this post Link to post Share on other sites
SpuddyGoggles 0 Posted April 9 1 minute ago, roninator2 said: How many equipment slots will you have? 0 - weapon 1 - shield 2 - helmet 3 - armor 4 - accessory etc Hmm, I'm thinking just Weapons, Armor, and Shield/Accessory(either would work, but not both) But I would be fine if it was just the first three slots since that would likely be easier rather than specific ones. Share this post Link to post Share on other sites
roninator2 257 Posted April 9 Ah, so you actually want the command window to be the slot window. weapon, shield, helmet, armor, accessory. But which ones. It makes a difference, because each item has it's own equip type (slot_id) You say armor, so that's the body armor? then you don't want shields or helmets? Share this post Link to post Share on other sites
SpuddyGoggles 0 Posted April 9 Yes, just the three slots. I want It to be rather simplistic. Sorry for not really making myself too clear. Share this post Link to post Share on other sites
roninator2 257 Posted April 9 (edited) Does this work? Spoiler # ╔═════════════════════════════════════╦════════════════════╗ # ║ Title: Minimal Equip Scene ║ Version: 1.00 ║ # ║ Author: Roninator2 ║ ║ # ╠═════════════════════════════════════╬════════════════════╣ # ║ Function: ║ Date Created ║ # ║ Alternate equip menu scene ╠════════════════════╣ # ║ ║ 09 Apr 2022 ║ # ╚═════════════════════════════════════╩════════════════════╝ # ╔══════════════════════════════════════════════════════════╗ # ║ Instructions: ║ # ║ Plug & Play ║ # ╚══════════════════════════════════════════════════════════╝ # ╔═════════════════════════════════════╗ # ║ Terms of use: ║ # ║ Free for all uses in RPG Maker ║ # ╚═════════════════════════════════════╝ #============================================================================== # ** Window_EquipCommand #------------------------------------------------------------------------------ # This window is for selecting commands (change equipment/ultimate equipment # etc.) on the skill screen. #============================================================================== class Window_EquipCategory < Window_Command #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y) clear_command_list make_command_list super(x, y) refresh select(0) activate end #-------------------------------------------------------------------------- # * Get Window Width #-------------------------------------------------------------------------- def window_width return 160 end #-------------------------------------------------------------------------- # * Get Window Height #-------------------------------------------------------------------------- def window_height fitting_height(4) end #-------------------------------------------------------------------------- # * Create Command List #-------------------------------------------------------------------------- def make_command_list add_command("Weapon", :eqweapon) add_command("Armor", :eqarmour) add_command("Accessory", :eqaccess) end #-------------------------------------------------------------------------- # * Set Item Window #-------------------------------------------------------------------------- def item_window=(item_window) @item_window = item_window update end end #============================================================================== # ** Window_EquipItem #------------------------------------------------------------------------------ # This window displays choices when opting to change equipment on the # equipment screen. #============================================================================== class Window_EquipItem < Window_ItemList #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :slot_id #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y, width, height) super @actor = nil @slot_id = 0 end #-------------------------------------------------------------------------- # * Set Actor #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor refresh self.oy = 0 end #-------------------------------------------------------------------------- # * Set Equipment Slot ID #-------------------------------------------------------------------------- def slot_id=(slot_id) return if @slot_id == slot_id @slot_id = slot_id refresh self.oy = 0 end #-------------------------------------------------------------------------- # * Include in Item List? #-------------------------------------------------------------------------- def include?(item) return true if item == nil return false unless item.is_a?(RPG::EquipItem) return false if @slot_id < 0 return false if item.etype_id != @actor.equip_slots[0] return false if item.etype_id != @actor.equip_slots[1] return @actor.equippable?(item) end #-------------------------------------------------------------------------- # * Display in Enabled State? #-------------------------------------------------------------------------- def enable?(item) return true end #-------------------------------------------------------------------------- # * Restore Previous Selection Position #-------------------------------------------------------------------------- def select_last end #-------------------------------------------------------------------------- # * Update Help Text #-------------------------------------------------------------------------- def update_help super if @actor && @status_window temp_actor = Marshal.load(Marshal.dump(@actor)) temp_actor.force_change_equip(@slot_id, item) @status_window.set_temp_actor(temp_actor) end end #-------------------------------------------------------------------------- # * Get Digit Count #-------------------------------------------------------------------------- def col_max return 1 end #-------------------------------------------------------------------------- # * Get Number of Items #-------------------------------------------------------------------------- def item_max @data ? @data.size : 1 end #-------------------------------------------------------------------------- # * Get Item #-------------------------------------------------------------------------- def item @data && index >= 0 ? @data[index] : nil end #-------------------------------------------------------------------------- # * Get Activation State of Selection Item #-------------------------------------------------------------------------- def current_item_enabled? enable?(@data[index]) end #-------------------------------------------------------------------------- # * Include in Item List? #-------------------------------------------------------------------------- def include?(item) case @slot_id when 0 item.is_a?(RPG::Weapon) && item.etype_id == 0 when 3 item.is_a?(RPG::Armor) && item.etype_id == 3 when 4 item.is_a?(RPG::Armor) && item.etype_id == 4 else false end end #-------------------------------------------------------------------------- # * Display if Equipped #-------------------------------------------------------------------------- def on_equipped?(item) @actor.equips[@slot_id] == item end #-------------------------------------------------------------------------- # * Create Item List #-------------------------------------------------------------------------- def make_item_list @data = $game_party.all_items.select {|item| include?(item) } @data.push(@actor.equips[slot_id]) @data.compact! @data.sort! {|a, b| a.id <=> b.id } @data.push(nil) if include?(nil) end #-------------------------------------------------------------------------- # * Restore Previous Selection Position #-------------------------------------------------------------------------- def select_last select(@data.index($game_party.last_item.object) || 0) end #-------------------------------------------------------------------------- # * Draw Item #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] if item rect = item_rect(index) rect.width -= 120 draw_item_name(item, rect.x, rect.y, enable?(item)) draw_equipped(item, rect.x, rect.y) if on_equipped?(item) end end #-------------------------------------------------------------------------- # * Draw Equipped Status #-------------------------------------------------------------------------- def draw_equipped(item, x, y, enabled = true, width = (Graphics.width - 160)) return unless item change_color(normal_color, enabled) draw_text(x - 40, y, width, line_height, ":Equipped", 2) end end #============================================================================== # ** Scene_Equip #------------------------------------------------------------------------------ # This class performs the equipment screen processing. #============================================================================== class Scene_Equip < Scene_MenuBase #-------------------------------------------------------------------------- # * Start Processing #-------------------------------------------------------------------------- def start super create_help_window create_command_window create_item_window end #-------------------------------------------------------------------------- # * Create Command Window #-------------------------------------------------------------------------- def create_command_window wy = Graphics.height - 120 @command_window = Window_EquipCategory.new(0, wy) @command_window.viewport = @viewport @command_window.set_handler(:eqweapon, method(:command_weapon)) @command_window.set_handler(:eqarmour, method(:command_armour)) @command_window.set_handler(:eqaccess, method(:command_access)) @command_window.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # * Create Item Window #-------------------------------------------------------------------------- def create_item_window wy = Graphics.height - 120 ww = Graphics.width - 160 @item_window = Window_EquipItem.new(160, wy, ww, 120) @item_window.viewport = @viewport @item_window.help_window = @help_window @item_window.actor = @actor @item_window.set_handler(:ok, method(:on_item_ok)) @item_window.set_handler(:cancel, method(:on_item_cancel)) @command_window.item_window = @item_window end #-------------------------------------------------------------------------- # * Item [OK] #-------------------------------------------------------------------------- def on_item_ok Sound.play_equip @actor.change_equip(determine_slot, check_item) @item_window.refresh @item_window.activate end #-------------------------------------------------------------------------- # * Item [Cancel] #-------------------------------------------------------------------------- def on_item_cancel @item_window.unselect @command_window.activate end #-------------------------------------------------------------------------- # * Change Actors #-------------------------------------------------------------------------- def check_item item = @item_window.item eqitem = @actor.equips[determine_slot] if item == eqitem return nil else return item end end #-------------------------------------------------------------------------- # * Equip Weapon #-------------------------------------------------------------------------- def command_weapon @item_window.activate @item_window.select(0) @item_window.slot_id=(0) end #-------------------------------------------------------------------------- # * Equip Armor #-------------------------------------------------------------------------- def command_armour @item_window.activate @item_window.select(0) @item_window.slot_id=(3) end #-------------------------------------------------------------------------- # * Equip Accessory #-------------------------------------------------------------------------- def command_access @item_window.activate @item_window.select(0) @item_window.slot_id=(4) end #-------------------------------------------------------------------------- # * Determine Slot #-------------------------------------------------------------------------- def determine_slot slot = @item_window.slot_id return slot end end Edited April 9 by roninator2 Share this post Link to post Share on other sites
SpuddyGoggles 0 Posted April 9 Sorry for the delay. It worked somewhat, but only when I don't have any items. When I do have a weapon or armor it just crashes and gives this error. Share this post Link to post Share on other sites
SpuddyGoggles 0 Posted April 9 Alright so I managed to "fix" it by simply commenting out the problematic bit of code. (I am not certain of it's importance.) And after some window size tweaks and command changes it seems to be working at least as I described. However it does have some issues that I probably should be able to fix on my own. Such as the help window being slightly inconsistent, the itemlist being incorrectly previewed, and the inability to 'unequip' items. Share this post Link to post Share on other sites
roninator2 257 Posted April 9 1 hour ago, SpuddyGoggles said: When I do have a weapon or armor it just crashes and gives this error. What other scripts do you have? That line simply reorganizes the items so that they are in order. Otherwise it swaps around so that the item you have equipped is at the bottom of the list. And it works perfectly for me in a blank demo. I found the problem. It is trying to sort nil values. I'm updating the code above. Didn't know you wanted to unequip. To do that I would simple change one method. There's also a method I forgot to remove. Why you had to make any changes, I don't know. Is your game running at 640x480? The script was made for 544x416. Share this post Link to post Share on other sites
SpuddyGoggles 0 Posted April 9 (edited) Yes it's still using the default sizing, I just changed the command window to be 120x120 rather than 120x160, along with changing the size of the item window to accommodate it. Edited April 10 by SpuddyGoggles Share this post Link to post Share on other sites
SpuddyGoggles 0 Posted April 10 (edited) Hmm, that's odd. Putting in a do block did nothing. Edited April 10 by SpuddyGoggles Share this post Link to post Share on other sites
roninator2 257 Posted April 10 I bet that when you changed the number for the size you removed a ) Share this post Link to post Share on other sites
SpuddyGoggles 0 Posted April 10 10 minutes ago, roninator2 said: I bet that when you changed the number for the size you removed a ) I have yet to have altered this newer version, I just pasted it in materials and hit playtest. Share this post Link to post Share on other sites
roninator2 257 Posted April 10 And my playtest works fine. Here it is again, with the size at 120 Spoiler # ╔═════════════════════════════════════╦════════════════════╗ # ║ Title: Minimal Equip Scene ║ Version: 1.00 ║ # ║ Author: Roninator2 ║ ║ # ╠═════════════════════════════════════╬════════════════════╣ # ║ Function: ║ Date Created ║ # ║ Alternate equip menu scene ╠════════════════════╣ # ║ ║ 09 Apr 2022 ║ # ╚═════════════════════════════════════╩════════════════════╝ # ╔══════════════════════════════════════════════════════════╗ # ║ Instructions: ║ # ║ Plug & Play ║ # ╚══════════════════════════════════════════════════════════╝ # ╔═════════════════════════════════════╗ # ║ Terms of use: ║ # ║ Free for all uses in RPG Maker ║ # ╚═════════════════════════════════════╝ #============================================================================== # ** Window_EquipCommand #------------------------------------------------------------------------------ # This window is for selecting commands (change equipment/ultimate equipment # etc.) on the skill screen. #============================================================================== class Window_EquipCategory < Window_Command #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y) clear_command_list make_command_list super(x, y) refresh select(0) activate end #-------------------------------------------------------------------------- # * Get Window Width #-------------------------------------------------------------------------- def window_width return 120 end #-------------------------------------------------------------------------- # * Get Window Height #-------------------------------------------------------------------------- def window_height fitting_height(4) end #-------------------------------------------------------------------------- # * Create Command List #-------------------------------------------------------------------------- def make_command_list add_command("Weapon", :eqweapon) add_command("Armor", :eqarmour) add_command("Trinket", :eqaccess) end #-------------------------------------------------------------------------- # * Set Item Window #-------------------------------------------------------------------------- def item_window=(item_window) @item_window = item_window update end end #============================================================================== # ** Window_EquipItem #------------------------------------------------------------------------------ # This window displays choices when opting to change equipment on the # equipment screen. #============================================================================== class Window_EquipItem < Window_ItemList #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :slot_id #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y, width, height) super @actor = nil @slot_id = 0 end #-------------------------------------------------------------------------- # * Set Actor #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor refresh self.oy = 0 end #-------------------------------------------------------------------------- # * Set Equipment Slot ID #-------------------------------------------------------------------------- def slot_id=(slot_id) return if @slot_id == slot_id @slot_id = slot_id refresh self.oy = 0 end #-------------------------------------------------------------------------- # * Include in Item List? #-------------------------------------------------------------------------- def include?(item) return true if item == nil return false unless item.is_a?(RPG::EquipItem) return false if @slot_id < 0 return false if item.etype_id != @actor.equip_slots[0] return false if item.etype_id != @actor.equip_slots[1] return @actor.equippable?(item) end #-------------------------------------------------------------------------- # * Display in Enabled State? #-------------------------------------------------------------------------- def enable?(item) return true end #-------------------------------------------------------------------------- # * Restore Previous Selection Position #-------------------------------------------------------------------------- def select_last end #-------------------------------------------------------------------------- # * Update Help Text #-------------------------------------------------------------------------- def update_help super if @actor && @status_window temp_actor = Marshal.load(Marshal.dump(@actor)) temp_actor.force_change_equip(@slot_id, item) @status_window.set_temp_actor(temp_actor) end end #-------------------------------------------------------------------------- # * Get Digit Count #-------------------------------------------------------------------------- def col_max return 1 end #-------------------------------------------------------------------------- # * Get Number of Items #-------------------------------------------------------------------------- def item_max @data ? @data.size : 1 end #-------------------------------------------------------------------------- # * Get Item #-------------------------------------------------------------------------- def item @data && index >= 0 ? @data[index] : nil end #-------------------------------------------------------------------------- # * Get Activation State of Selection Item #-------------------------------------------------------------------------- def current_item_enabled? enable?(@data[index]) end #-------------------------------------------------------------------------- # * Include in Item List? #-------------------------------------------------------------------------- def include?(item) case @slot_id when 0 item.is_a?(RPG::Weapon) && item.etype_id == 0 when 3 item.is_a?(RPG::Armor) && item.etype_id == 3 when 4 item.is_a?(RPG::Armor) && item.etype_id == 4 else false end end #-------------------------------------------------------------------------- # * Display if Equipped #-------------------------------------------------------------------------- def on_equipped?(item) @actor.equips[@slot_id] == item end #-------------------------------------------------------------------------- # * Create Item List #-------------------------------------------------------------------------- def make_item_list @data = $game_party.all_items.select {|item| include?(item) } @data.push(@actor.equips[slot_id]) @data.compact! @data.sort! {|a, b| a.id <=> b.id } @data.push(nil) if include?(nil) end #-------------------------------------------------------------------------- # * Restore Previous Selection Position #-------------------------------------------------------------------------- def select_last select(@data.index($game_party.last_item.object) || 0) end #-------------------------------------------------------------------------- # * Draw Item #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] if item rect = item_rect(index) rect.width -= 120 draw_item_name(item, rect.x, rect.y, enable?(item)) draw_equipped(item, rect.x, rect.y) if on_equipped?(item) end end #-------------------------------------------------------------------------- # * Draw Equipped Status #-------------------------------------------------------------------------- def draw_equipped(item, x, y, enabled = true, width = (Graphics.width - 120)) return unless item change_color(normal_color, enabled) draw_text(x - 40, y, width, line_height, ":Equipped", 2) end end #============================================================================== # ** Scene_Equip #------------------------------------------------------------------------------ # This class performs the equipment screen processing. #============================================================================== class Scene_Equip < Scene_MenuBase #-------------------------------------------------------------------------- # * Start Processing #-------------------------------------------------------------------------- def start super create_help_window create_command_window create_item_window end #-------------------------------------------------------------------------- # * Create Command Window #-------------------------------------------------------------------------- def create_command_window wy = Graphics.height - 120 @command_window = Window_EquipCategory.new(0, wy) @command_window.viewport = @viewport @command_window.set_handler(:eqweapon, method(:command_weapon)) @command_window.set_handler(:eqarmour, method(:command_armour)) @command_window.set_handler(:eqaccess, method(:command_access)) @command_window.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # * Create Item Window #-------------------------------------------------------------------------- def create_item_window wy = Graphics.height - 120 ww = Graphics.width - 120 @item_window = Window_EquipItem.new(120, wy, ww, 120) @item_window.viewport = @viewport @item_window.help_window = @help_window @item_window.actor = @actor @item_window.set_handler(:ok, method(:on_item_ok)) @item_window.set_handler(:cancel, method(:on_item_cancel)) @command_window.item_window = @item_window end #-------------------------------------------------------------------------- # * Item [OK] #-------------------------------------------------------------------------- def on_item_ok Sound.play_equip @actor.change_equip(determine_slot, check_item) @item_window.refresh @item_window.activate end #-------------------------------------------------------------------------- # * Item [Cancel] #-------------------------------------------------------------------------- def on_item_cancel @item_window.unselect @command_window.activate end #-------------------------------------------------------------------------- # * Change Actors #-------------------------------------------------------------------------- def check_item item = @item_window.item eqitem = @actor.equips[determine_slot] if item == eqitem return nil else return item end end #-------------------------------------------------------------------------- # * Equip Weapon #-------------------------------------------------------------------------- def command_weapon @item_window.activate @item_window.select(0) @item_window.slot_id=(0) end #-------------------------------------------------------------------------- # * Equip Armor #-------------------------------------------------------------------------- def command_armour @item_window.activate @item_window.select(0) @item_window.slot_id=(3) end #-------------------------------------------------------------------------- # * Equip Accessory #-------------------------------------------------------------------------- def command_access @item_window.activate @item_window.select(0) @item_window.slot_id=(4) end #-------------------------------------------------------------------------- # * Determine Slot #-------------------------------------------------------------------------- def determine_slot slot = @item_window.slot_id return slot end end Share this post Link to post Share on other sites
SpuddyGoggles 0 Posted April 10 (edited) It works perfectly! I'm not certain what I did to cause the error though. Thank you for the help though! It's almost exactly what I wanted! Edited April 10 by SpuddyGoggles Share this post Link to post Share on other sites