european_son
Member
I'm working on a CMS which is supposed to show the actor states as icons. I've managed to get this working fine in Window_Status:
The problem is that this code doesn't work in Window_MenuStatus or Window_Target. NoMethodError occurs instead ("undefined method 'states' for NilClass").
Can anyone help? Thanks in advance!
Code:
  # Draw condition icons
  if @actor.states.include?(1)
   bitmap = RPG::Cache.icon("icon_symbol_death")
   self.contents.blt(0, 400, bitmap, Rect.new(0, 0, 24, 24), 200)
  else
   bitmap = RPG::Cache.icon("icon_symbol_death_g")
   self.contents.blt(0, 400, bitmap, Rect.new(0, 0, 24, 24), 60)
  end
  if @actor.states.include?(2)
   bitmap = RPG::Cache.icon("icon_symbol_blood")
   self.contents.blt(24, 400, bitmap, Rect.new(0, 0, 24, 24), 200)
  else
   bitmap = RPG::Cache.icon("icon_symbol_blood_g")
   self.contents.blt(24, 400, bitmap, Rect.new(0, 0, 24, 24), 60)
  end
  if @actor.states.include?(3)
   bitmap = RPG::Cache.icon("icon_symbol_fire")
   self.contents.blt(48, 400, bitmap, Rect.new(0, 0, 24, 24), 200)
  else
   bitmap = RPG::Cache.icon("icon_symbol_fire_g")
   self.contents.blt(48, 400, bitmap, Rect.new(0, 0, 24, 24), 60)
  end
  if @actor.states.include?(4)
   bitmap = RPG::Cache.icon("icon_symbol_hunger")
   self.contents.blt(72, 400, bitmap, Rect.new(0, 0, 24, 24), 200)
  else
   bitmap = RPG::Cache.icon("icon_symbol_hunger_g")
   self.contents.blt(72, 400, bitmap, Rect.new(0, 0, 24, 24), 60)
  end
  if @actor.states.include?(5)
   bitmap = RPG::Cache.icon("icon_symbol_toxic")
   self.contents.blt(96, 400, bitmap, Rect.new(0, 0, 24, 24), 200)
  else
   bitmap = RPG::Cache.icon("icon_symbol_toxic_g")
   self.contents.blt(96, 400, bitmap, Rect.new(0, 0, 24, 24), 60)
  end
  if @actor.states.include?(6)
   bitmap = RPG::Cache.icon("icon_symbol_bio")
   self.contents.blt(120, 400, bitmap, Rect.new(0, 0, 24, 24), 200)
  else
   bitmap = RPG::Cache.icon("icon_symbol_bio_g")
   self.contents.blt(120, 400, bitmap, Rect.new(0, 0, 24, 24), 60)
  end
  if @actor.states.include?(7)
   bitmap = RPG::Cache.icon("icon_symbol_rad")
   self.contents.blt(144, 400, bitmap, Rect.new(0, 0, 24, 24), 200)
  else
   bitmap = RPG::Cache.icon("icon_symbol_rad_g")
   self.contents.blt(144, 400, bitmap, Rect.new(0, 0, 24, 24), 60)
  end
  if @actor.states.include?(8)
   bitmap = RPG::Cache.icon("icon_symbol_psi")
   self.contents.blt(168, 400, bitmap, Rect.new(0, 0, 24, 24), 200)
  else
   bitmap = RPG::Cache.icon("icon_symbol_psi_g")
   self.contents.blt(168, 400, bitmap, Rect.new(0, 0, 24, 24), 60)
  end
Â
The problem is that this code doesn't work in Window_MenuStatus or Window_Target. NoMethodError occurs instead ("undefined method 'states' for NilClass").
Can anyone help? Thanks in advance!