Ok,im puting a cursed weapon script in my game but i keep getting an error
http://www.phylomortis.com/resource/script/scr025.html
this is where the script is
the chunk im having a problem with is
def draw_item_name(item, x, y)
if item == nil
return
end
bitmap = RPG::Cache.icon(item.icon_name)
if item.is_a?(RPG::Weapon) && $game_system.cursed_weapons.include?(item.id)
self.contents.font.color = cursed_color
end
if item.is_a?(RPG::Armor) && $game_system.cursed_armors.include?(item.id)
self.contents.font.color = cursed_color
end
self.contents.draw_text(x + 28, y, 212, 32, item.name)
end
def initialize(actor)
super(272, 64, 368, 192)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
self.index = 0
end
My error is: when i open my menu and go to the equips tab and open it i get this error
-------------------------
Script 'Window_EquipRight' line 15: NoMethodError occurred.
undefined method `include?' for nil:NilClass
-------------------------
QuoteTo use this script, first add the two global variables to Game_System, as shown, the replace Scene_Equip#update_right with the code provided. Then, add the new methods Window_EquipRight#draw_item_name and Window_Base#cursed_color. To add a cursed weapon, add the weapon's database ID to the "cursed_weapons" array in Game_System. To add a cursed armor, add the armor's database ID to the "cursed_armors" array in Game_System.
That means find that Update_Right section in Scene_Equip and replace it.
Im still getting the error
---------------------------
Project3
---------------------------
Script 'Window_EquipRight' line 62: NoMethodError occurred.
undefined method `include?' for nil:NilClass
---------------------------
OK
---------------------------
The error means that cursed_weapons from the Game_System class is nil.
You can think of it as if it doesn't exists.
Are you sure you have initialized the variables in Game_System like you should?
I don't like that you can't by color alone see which equipped item is cursed. All are just the same color.
Edit: The color problem is easily fixed. Replace the first with the latter in class Window_EquipRight < Window_Selectable
# ---------------------------
def draw_item_name(item, x, y)
if item == nil
return
end
bitmap = RPG::Cache.icon(item.icon_name)
if item.is_a?(RPG::Weapon) && $game_system.cursed_weapons.include?(item.id)
self.contents.font.color = cursed_color
end
if item.is_a?(RPG::Armor) && $game_system.cursed_armors.include?(item.id)
self.contents.font.color = cursed_color
end
self.contents.draw_text(x + 28, y, 212, 32, item.name)
end
# ---------------------------
def draw_item_name(item, x, y)
if item == nil
return
end
self.contents.font.color = normal_color
bitmap = RPG::Cache.icon(item.icon_name)
if item.is_a?(RPG::Weapon) && $game_system.cursed_weapons.include?(item.id)
self.contents.font.color = cursed_color
end
if item.is_a?(RPG::Armor) && $game_system.cursed_armors.include?(item.id)
self.contents.font.color = cursed_color
end
self.contents.draw_text(x + 28, y, 212, 32, item.name)
end
The quick will notice that I've only added self.contents.font.color = normal_color
As I said, simple fix.