RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

I need Script Help

Started by Red Eye Dragoon, March 18, 2006, 01:07:52 AM

0 Members and 1 Guest are viewing this topic.

Red Eye Dragoon

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
-------------------------
Major Project : Cliche Cronicles
Total: [llllllllllllllllllll] 0%
Story: [llllllllllllllllllll] 0%
Resources: [llllllllllllllllllll] 0%
Script: [llllllllllllllllllll] 0%
Voice Overs: [llllllllllllllllllll] 0%

Currently: Planning

Dalton

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.

Red Eye Dragoon

Im still getting the error

---------------------------
Project3
---------------------------
Script 'Window_EquipRight' line 62: NoMethodError occurred.

undefined method `include?' for nil:NilClass
---------------------------
OK  
---------------------------
Major Project : Cliche Cronicles
Total: [llllllllllllllllllll] 0%
Story: [llllllllllllllllllll] 0%
Resources: [llllllllllllllllllll] 0%
Script: [llllllllllllllllllll] 0%
Voice Overs: [llllllllllllllllllll] 0%

Currently: Planning

Zeriab

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.