Hey, guys. I need help with a script I created on my own.
I am terrible at this so I created some kind of monstruosity I called
Status Smashed Equip. My intention was to combine Scene_Status with Scene_Equip letting the player change his equipment
directly from Window_Status, but I've got this error. 😩
This happens when I try to access Scene_Status when no weapon is equipped and when I have any weapon in the inventory. I have tested this script in a fresh project, so it's not conflicting with other custom scripts.
Please, I know this script is literal chaos, but probably not too much for an actual scripter,, so if you have just a little enough time to help an disgusting noob like me, I will be very thankful. 🙏
Thank you very much.
😢
I am terrible at this so I created some kind of monstruosity I called
Status Smashed Equip. My intention was to combine Scene_Status with Scene_Equip letting the player change his equipment
directly from Window_Status, but I've got this error. 😩
Script "LEO Simple Equip Status" line 387: NoMethodError ocurred.
endefined method 'equippable?' for nil:NilClass
endefined method 'equippable?' for nil:NilClass
This happens when I try to access Scene_Status when no weapon is equipped and when I have any weapon in the inventory. I have tested this script in a fresh project, so it's not conflicting with other custom scripts.
Please, I know this script is literal chaos, but probably not too much for an actual scripter,, so if you have just a little enough time to help an disgusting noob like me, I will be very thankful. 🙏
Code:
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
# This window displays full status specs on the status screen.
#==============================================================================
class Window_Status < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor)
super(125, 15, 300, line_height * 16)
@actor = actor
refresh
activate
end
#--------------------------------------------------------------------------
# * Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_block1 (line_height * 0)
draw_horz_line(line_height * 1)
draw_block2 (line_height * 2)
draw_horz_line(line_height * 6)
draw_block3 (line_height * 7)
draw_horz_line(line_height * 11)
draw_block4 (line_height * 12)
end
#--------------------------------------------------------------------------
# * Draw Block 1
#--------------------------------------------------------------------------
def draw_block1(y)
draw_actor_name(@actor, 4, y)
#~ draw_actor_class(@actor, 128, y)
draw_actor_nickname(@actor, 125, y)
end
#--------------------------------------------------------------------------
# * Draw Block 2
#--------------------------------------------------------------------------
def draw_block2(y)
draw_actor_face(@actor, 8, y)
draw_basic_info(136, y)
#~ draw_exp_info(304, y)
end
#--------------------------------------------------------------------------
# * Draw Block 3
#--------------------------------------------------------------------------
def draw_block3(y)
draw_parameters(50, y)
#~ draw_equipments(288, y)
end
#--------------------------------------------------------------------------
# * Draw Block 4
#--------------------------------------------------------------------------
def draw_block4(y)
draw_text_ex(70, (line_height * 12) + 6, "ARMA EQUIPADA:")
draw_equipments(96, (line_height * 13) + 23)
end
#--------------------------------------------------------------------------
# * Draw Horizontal Line
#--------------------------------------------------------------------------
def draw_horz_line(y)
line_y = y + line_height / 2 - 1
contents.fill_rect(0, line_y, contents_width, 2, line_color)
end
#--------------------------------------------------------------------------
# * Get Color of Horizontal Line
#--------------------------------------------------------------------------
def line_color
color = normal_color
color.alpha = 48
color
end
#--------------------------------------------------------------------------
# * Draw Basic Information
#--------------------------------------------------------------------------
def draw_basic_info(x, y)
draw_actor_level(@actor, x, y + line_height * 0)
draw_actor_icons(@actor, x, y + line_height * 1)
draw_actor_hp(@actor, x, y + line_height * 2)
draw_actor_mp(@actor, x, y + line_height * 3)
end
#--------------------------------------------------------------------------
# * Draw Parameters
#--------------------------------------------------------------------------
def draw_parameters(x, y)
#~ 4.times {|i| draw_actor_param(@actor, x, y + line_height * i, i) }
draw_actor_param(@actor, x, y, 2)
draw_actor_param(@actor, x, y + line_height * 1, 0)
draw_actor_param(@actor, x, y + line_height * 2, 1)
draw_actor_param(@actor, x, y + line_height * 3, 4)
end
#--------------------------------------------------------------------------
# * Draw Equipment
#--------------------------------------------------------------------------
def draw_equipments(x, y)
@actor.equips.each_with_index do |item, i|
draw_item_name(item, x, y + line_height * i)
end
end
end
#==============================================================================
# ** Scene_Status
#------------------------------------------------------------------------------
# This class performs the status screen processing.
#==============================================================================
class Scene_Status < Scene_MenuBase
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
create_item_window
create_slot_window
@status_window = Window_Status.new(@actor)
@status_window.set_handler(:cancel, method(:return_scene))
@status_window.set_handler(:pagedown, method(:next_actor))
@status_window.set_handler(:ok, method(:create_slot_window))
end
#--------------------------------------------------------------------------
# * Change Actors
#--------------------------------------------------------------------------
def on_actor_change
@status_window.actor = @actor
@slot_window.actor = @actor
@item_window.actor = @actor
end
##--------------------------------------------------------------------------
## * Create Equip Window
##--------------------------------------------------------------------------
def create_slot_window
wx = 125
wy = 350
ww = 300
wh = 50
@slot_window = Window_EquipSlot.new(wx, wy, ww, wh)
@slot_window.viewport = @viewport
@slot_window.open
@slot_window.activate
@slot_window.select(0)
@slot_window.help_window = @help_window
@slot_window.status_window = @status_window
@slot_window.actor = @actor
@slot_window.set_handler(:ok, method(:on_slot_ok))
#~ @slot_window.set_handler(:pageup, method(:on_slot_cancel))
@slot_window.set_handler(:cancel, method(:on_slot_cancel))
end
#--------------------------------------------------------------------------
# * Slot [OK]
#--------------------------------------------------------------------------
def on_slot_ok
@item_window.activate
@item_window.open
@slot_window.open
@item_window.select(0)
@status_window.refresh
end
#--------------------------------------------------------------------------
# * Slot [Cancel]
#--------------------------------------------------------------------------
def on_slot_cancel
@slot_window.close
@status_window.activate
@status_window.refresh
end
#--------------------------------------------------------------------------
# * Create Item Window
#--------------------------------------------------------------------------
def create_item_window
wx = 125
wy = 15
ww = 300
wh = Graphics.height - 247
@item_window = Window_EquipItem.new(wx, wy, ww, wh)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.status_window = @status_window
@item_window.actor = @actor
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
#~ @slot_window.item_window = @item_window
end
#--------------------------------------------------------------------------
# * Item [OK]
#--------------------------------------------------------------------------
def on_item_ok
Sound.play_equip
@actor.change_equip(@slot_window.index, @item_window.item)
#~ @slot_window.activate
#~ @slot_window.open
#~ @slot_window.refresh
@item_window.unselect
@item_window.refresh
@status_window.refresh
@item_window.close
on_slot_cancel
#~ @item_window.deactivate
end
#--------------------------------------------------------------------------
# * Item [Cancel]
#--------------------------------------------------------------------------
def on_item_cancel
@slot_window.activate
@item_window.deactivate
@item_window.close
@item_window.unselect
@status_window.refresh
@item_window.refresh
end
end
#==============================================================================
# ** Window_EquipSlot
#------------------------------------------------------------------------------
# This window displays items the actor is currently equipped with on the
# equipment screen.
#==============================================================================
class Window_EquipSlot < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :status_window # Status window
attr_reader :item_window # Item window
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@actor = nil
self.openness = 0
self.opacity = 0
deactivate
refresh
end
#--------------------------------------------------------------------------
# * Get Window Height
#--------------------------------------------------------------------------
def window_height
fitting_height(visible_line_number)
end
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
return 5
end
#--------------------------------------------------------------------------
# * Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
@item_window.slot_id = index if @item_window
end
#--------------------------------------------------------------------------
# * Get Number of Items
#--------------------------------------------------------------------------
def item_max
@actor ? @actor.equip_slots.size : 0
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
@actor ? @actor.equips[index] : nil
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
return unless @actor
rect = item_rect_for_text(index)
change_color(system_color, enable?(index))
draw_text(rect.x, rect.y, 92, line_height, slot_name(index))
draw_item_name(@actor.equips[index], rect.x + 92, rect.y, enable?(index))
end
#--------------------------------------------------------------------------
# * Get Equipment Slot Name
#--------------------------------------------------------------------------
def slot_name(index)
@actor ? Vocab::etype(@actor.equip_slots[index]) : ""
end
#--------------------------------------------------------------------------
# * Display Equipment Slot in Enabled State?
#--------------------------------------------------------------------------
def enable?(index)
@actor ? @actor.equip_change_ok?(index) : false
end
#--------------------------------------------------------------------------
# * Get Activation State of Selection Item
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(index)
end
#--------------------------------------------------------------------------
# * Set Status Window
#--------------------------------------------------------------------------
def status_window=(status_window)
@status_window = status_window
call_update_help
end
#--------------------------------------------------------------------------
# * Set Item Window
#--------------------------------------------------------------------------
def item_window=(item_window)
@item_window = item_window
update
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
super
@help_window.set_item(item) if @help_window
@status_window.set_temp_actor(nil) if @status_window
end
end
class Window_EquipItem < Window_ItemList
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :status_window # Status window
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super
self.openness = 0
@actor = nil
@slot_id = 0
deactivate
refresh
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 != 0
return @actor.equippable?(item)
end
#--------------------------------------------------------------------------
# * Display in Enabled State?
#--------------------------------------------------------------------------
def enable?(item)
return true
end
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
def select_last
end
#--------------------------------------------------------------------------
# * Set Status Window
#--------------------------------------------------------------------------
def status_window=(status_window)
@status_window = status_window
call_update_help
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
end
Thank you very much.
😢