How to change priority_type of specific event?

Hi,

i was reading the data structure documented in the chm file, because of this i was thinking i could access and change the attribute using the following command:
Ruby:
# 1. access current map
# 2. access event 002
# 3. access page 1 <-- does not work
# 4. set priority_type to "Above Characters"
$game_map.events[1].pages[0].priority_type = 2

for some reason the game tells me there is no method named "pages" which confuses me since i try to access the attribute and not calling a method... (maybe im just dumb atm)

there was another person on steam that asked this question for years without getting any answer, i hope its not something too basic and somebody could tell me what i am doing wrong (without having me wait so long). 😅

best regards,
Regda
Ruby:
class Game_Event
  attr_reader :pages
end
Ruby:
class Game_Event
  attr_reader :pages
end
Sry i don't know what to do with that, can you explain it ?

I try to access an event on a map, not an common event.

EDIT:
ok i solved it by writing an method instead of making the attribute public.
Copy the following into the scripteditor at the materials section:

Ruby:
class Game_Event
  #--------------------------------------------------------------------------
  # * change_priority_type
  #--------------------------------------------------------------------------
  def change_priority_type(page_id, priority)
    @event.pages[page_id].priority_type = priority
  end
end

Then use it like:

Ruby:
# where event is my event 002 on the current map
# parameter 1: 0 means page nr.1
# parameter 2: 2 means above player prio.
$game_map.events[2].change_priority_type(0, 2)

Original thread: https://forums.rpgmakerweb.com/threads/how-to-change-priority_type-of-specific-event.156212/