Help with a String for Yanfly's Lunatic Target?

Hellu again! So, I'm trying to create a String for Lunatic Target so a skill I make can only target an enemy that have 3 or more states on them.

Also, I'm using this mini script (that I can't remember where I take from).

Ruby:
class RPG::State < RPG::BaseItem
  def neg_state?
    self.note =~ /<neg>/i
  end
 
  def spell_state?
    self.note =~ /<spell>/i
  end
 
  def trap_state?
    self.note =~ /<trap>/i
  end
 
  def spelltrap_state?
    self.note =~ /<spelltrap>/i
  end
 
  def faceupst_state?
    self.note =~ /<faceupst>/i
  end
 
  def monster_state?
    self.note =~ /<monst>/i
  end
 
  def set_state?
    self.note =~ /<set>/i
  end
 
end

class Game_Battler < Game_BattlerBase
 
  def remove_random_state
    return if neg_states_and_debuffs.empty?
    state_id = neg_states_and_debuffs.sample
    state_id.is_a?(Array) ? remove_buff(state_id[0]) : remove_state(state_id)
  end
 
  def neg_states_and_debuffs
    debuffs = Hash[@buffs.map.with_index { |x,i| [i,x] }]
    debuffs = (debuffs.select { |k,v| v < 0 }).to_a
    return @states.select { |s| $data_states[s].neg_state? } + debuffs
  end
 
  def remove_random_spell
    return if neg_spell.empty?
    state_id = neg_spell.sample
    state_id.is_a?(Array) ? remove_buff(state_id[0]) : remove_state(state_id)
  end
 
  def neg_spell
    debuffs = Hash[@buffs.map.with_index { |x,i| [i,x] }]
    debuffs = (debuffs.select { |k,v| v < 0 }).to_a
    return @states.select { |s| $data_states[s].spell_state? } + debuffs
  end
 
  def remove_random_trap
    return if neg_trap.empty?
    state_id = neg_trap.sample
    state_id.is_a?(Array) ? remove_buff(state_id[0]) : remove_state(state_id)
  end
 
  def neg_trap
    debuffs = Hash[@buffs.map.with_index { |x,i| [i,x] }]
    debuffs = (debuffs.select { |k,v| v < 0 }).to_a
    return @states.select { |s| $data_states[s].trap_state? } + debuffs
  end
 
  def remove_random_spelltrap
    return if neg_spelltrap.empty?
    state_id = neg_spelltrap.sample
    state_id.is_a?(Array) ? remove_buff(state_id[0]) : remove_state(state_id)
  end
 
  def neg_spelltrap
    debuffs = Hash[@buffs.map.with_index { |x,i| [i,x] }]
    debuffs = (debuffs.select { |k,v| v < 0 }).to_a
    return @states.select { |s| $data_states[s].spelltrap_state? } + debuffs
  end
 
  def remove_random_faceupst
    return if neg_faceupst.empty?
    state_id = neg_faceupst.sample
    state_id.is_a?(Array) ? remove_buff(state_id[0]) : remove_state(state_id)
  end
 
  def neg_faceupst
    debuffs = Hash[@buffs.map.with_index { |x,i| [i,x] }]
    debuffs = (debuffs.select { |k,v| v < 0 }).to_a
    return @states.select { |s| $data_states[s].faceupst_state? } + debuffs
  end
 
  def remove_random_monst
    return if neg_monst.empty?
    state_id = neg_monst.sample
    state_id.is_a?(Array) ? remove_buff(state_id[0]) : remove_state(state_id)
  end
 
  def neg_monst
    debuffs = Hash[@buffs.map.with_index { |x,i| [i,x] }]
    debuffs = (debuffs.select { |k,v| v < 0 }).to_a
    return @states.select { |s| $data_states[s].monst_state? } + debuffs
  end
    
  def remove_random_set
    return if neg_set.empty?
    state_id = neg_set.sample
    state_id.is_a?(Array) ? remove_buff(state_id[0]) : remove_state(state_id)
  end
 
  def neg_set
    debuffs = Hash[@buffs.map.with_index { |x,i| [i,x] }]
    debuffs = (debuffs.select { |k,v| v < 0 }).to_a
    return @states.select { |s| $data_states[s].set_state? } + debuffs
  end
 
end

This mini script allow me to give states specific notetags to keep record of them and give them special traits with other scripts. ANYWAYS, the problem is, I have an skill that should only target an enemy that have 3 or more states with the notetag <spelltrap>, but I can't figure out how should I create said string.

Any help is welcome. Thanks!
Two things that you haven't noticed here. Since you're working on extending RPG::State, you don't need to redeclare the parent class aka superclass with a < RPG::BaseItem. The hidden scripts already did that for you. You just need to reopen the existing class RPG::State and that's it. The other thing is that you don't need to call self.note every single time you need to check a note. Actually the most direct way to do it is using @note instead. If you ever alias note, you really gotta have a serious problem affecting your mind.

I guess you could either call select or any? with that note as a condition, assign its result to a local variable and then check if its size is greater or equal to 3.
Two things that you haven't noticed here. Since you're working on extending RPG::State, you don't need to redeclare the parent class aka superclass with a < RPG::BaseItem. The hidden scripts already did that for you. You just need to reopen the existing class RPG::State and that's it. The other thing is that you don't need to call self.note every single time you need to check a note. Actually the most direct way to do it is using @note instead. If you ever alias note, you really gotta have a serious problem affecting your mind.

I guess you could either call select or any? with that note as a condition, assign its result to a local variable and then check if its size is greater or equal to 3.
1688140186887.png


(sorry, I'm very dumb when it came to ruby)

Original thread: https://forums.rpgmakerweb.com/threads/help-with-a-string-for-yanflys-lunatic-target.158793/