RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
I need Script Help

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 90
I have game maker's block PM me with game ideas.
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
Code: [Select]

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

***
Rep:
Level 90
~
Quote
To 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.

***
Rep:
Level 90
I have game maker's block PM me with game ideas.
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

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
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
Code: [Select]
# ---------------------------
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

Code: [Select]
 # ---------------------------
  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.