(SOLVED)Event comment override for YANFLYS Move Restrict Region

so first of all I am making a modification to YANFLYS Move Restrict Region script here https://yanflychannel.wordpress.com/rmvxa/field-scripts/move-restrict-region/
I am back asking for help with another modification to this script. I thought of doing this on my first post on the script but I called it solved and it's supposed to be closed. I have an enemy that I recently added that can take on the looks and ability of other enemies one of which was my first post on this script. Now the method for that one was naming the event flying beast. but from what I researched just renaming my shapeshifting event. Whenever it becomes the flying enemy was difficult and would not work.

So what my sleep-deprived brain is getting at is I needed to find a new method that gave me control to overrides the event overall region restrict on and off. My solution is to use event comments. I thought it was going to be easy but I hit roadblocks my good news is I have scripts that read the event comments already it just that yanfly script won't use it

here is one way I tried for testing it to get it to work
Code:
  def npc_exclude_allow?(x, y, d)
    return false unless self.is_a?(Game_Event)
    region = 0
    case d
    when 1; region = $game_map.region_id(x-1, y+1)
    when 2; region = $game_map.region_id(x+0, y+1)
    when 3; region = $game_map.region_id(x+1, y+1)
    when 4; region = $game_map.region_id(x-1, y+0)
    when 5; region = $game_map.region_id(x+0, y+0)
    when 6; region = $game_map.region_id(x+1, y+0)
    when 7; region = $game_map.region_id(x-1, y-1)
    when 8; region = $game_map.region_id(x+0, y-1)
    when 9; region = $game_map.region_id(x+1, y-1)
    end
    text = "#{YEA::MOVE_RESTRICT::EXCLUDE_NPC}"

    if $game_map.events[1].note == (/<flight>/)
      return true
    end
    
    return false if $game_map.npc_restrict_regions.include?(region)
    if @event.name.downcase.include?(text.downcase)
      return true
    end
    return false
  end
 
  def note
    event_note = @event.note
    p(@event.note)
   /<flight>/ =~ event_note
   return false unless $~
   return true
  end
Borrowed some code ideas from Shaz Mouse
just put a comment on the page for the event when you want the event to fly and use self switch or other condition to change the active page.
Ruby:
class Game_CharacterBase
  def npc_exclude_allow?(x, y, d)
    return false unless self.is_a?(Game_Event)
    region = 0
    case d
    when 1; region = $game_map.region_id(x-1, y+1)
    when 2; region = $game_map.region_id(x+0, y+1)
    when 3; region = $game_map.region_id(x+1, y+1)
    when 4; region = $game_map.region_id(x-1, y+0)
    when 5; region = $game_map.region_id(x+0, y+0)
    when 6; region = $game_map.region_id(x+1, y+0)
    when 7; region = $game_map.region_id(x-1, y-1)
    when 8; region = $game_map.region_id(x+0, y-1)
    when 9; region = $game_map.region_id(x+1, y-1)
    end
    text = "#{YEA::MOVE_RESTRICT::EXCLUDE_NPC}"
    if @event.name.downcase.include?(text.downcase)
      return true
    end
    for i in 0..@pass_region.size - 1
      next if @pass_region[i].parameters[0].nil?
      next if !@pass_region[i].parameters[0].instance_of?(String)
      return true if @pass_region[i].parameters[0].downcase.include?(text.downcase)
      return true if @pass_region[i].parameters[0].upcase.include?(text.upcase)

    end
    return false
  end
end

module RPG
  class Event
    class Page
      def check_flying
        list.each do |command|
          if [108, 408].include?(command.code)
            comment = command.parameters[0]
              case comment
              when /"#{YEA::MOVE_RESTRICT::EXCLUDE_NPC}"/i
                @pass_region = true
              end
          end
        end
      end
    end
  end
end
class Game_Event < Game_Character
  alias r2_game_event_setup_page_settings_region_block setup_page_settings
  def setup_page_settings
    r2_game_event_setup_page_settings_region_block
    @page.check_flying
    @pass_region = @page.check_flying
  end
end
brain kinda being stupid do I just need to put a comment on one the pages or do I need to put check_flying or fly or something like that in the comment. I can't find what the exact command is
I can't find what the exact command is
The same that is in the script line 153. it can be capitalized or lower case.
Place the comment on the event page for when the event is to be 'flying' and no flying comment on the other event pages.
so I did that and it's still not working is there something I am missing
storage code.png
still not working
Sorry if it wasn't clear. What is your line in the script for the text?
By default is it EXCLUDE_NPC = "flying"
You have 'flying beast' in the comment. Might be the reason.
I have EXCLUDE_NPC = "Flying Beast". I tried this on a clean project and it still didn't want to work. am I formatting the comment wrong
am I formatting the comment wrong
my mistake. I edited the code above. Try it again.
okay now it works in a clean project sadly however I am getting this error in my project
storage code.png

I think it is one of my other scripts causing it just don't have the time right now to go through each one
getting this error in my project
I added one more line to do a check for string values.
that did the trick it works like a charm now thank you for the help. this thread can be closed

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-event-comment-override-for-yanflys-move-restrict-region.136664/