Temporarily remove a page from an event

Temporarily Remove Page From Event
by Khale_Kitha

Introduction
Allows the designer to temporarily remove a specified page from an event.  Though the event will continue to process until it reaches it's end, this allows the designer to have parallel process pages on an event that execute once and then remove themselves until the player re-enters the map.

How to Use
Paste above main.
Inside of an event page, use $game_map.events[id].remove_page(#), where id is the event id you wish to modify and # is the page on that event.

Alternate usages:

  - You may choose to use remove_current_page to remove the currently active page on an event.  (According to find_proper_page)  Eg. $game_map.events[id].remove_current_page

  - You may also choose to simply use the code segment 'remove_current_page' from the script of an event to remove the currently active page of the event you are on.

  - There are aliases for each of the methods, as well, if you are running out of space in your script block, but they shouldn't be needed.

Note:

The script simply removes the page and then checks the event, again, to see which page is the next valid page.  The current page will continue to execute until it finishes and then it will not exist again, until the player re-enters the map.  This works similarly to "Erase" for an event, but it allows full functionality of an event to exist without having multiple events for one purpose.  An example of it's use will be illustrated in an upcoming tutorial, in the next few days.

When choosing a page, pick the number listed in the UI, rather than the data page index.  I did this to make it easier on people who don't think in a 0-based indexing system to be able to wrap their head around the script.  (If you want it to be 0-based, simply remove the -1 from the script)

Script

Spoiler
#===============================================================================
#
# Temporarily Remove Page From Event
# Author: Khale_Kitha
# Date (07/07/2013)
# Version: (1.0.1) (VXA)
# Level: (Easy)
#
#===============================================================================
#
# NOTES:# 1. The script simply removes the page and then checks the event, again, to see which page is the next valid page.  The current page will continue to execute until it finishes and

# then it will not exist again, until the player re-enters the map.  This works similarly to "Erase" for an event, but it allows full functionality of an event to exist without having multiple

# events for one purpose

# 2.  When choosing a page, pick the number listed in the UI, rather than the data page index.  I did this to make it easier on people who don't think in a 0-based indexing system

# to be able to wrap their head around the script.  (If you want it to be 0-based, simply remove the -1 from the script)
#
#===============================================================================
#
# Description: Allows the designer to temporarily remove a specified page from an event.
#
# Credits: Khale_Kitha
#
#===============================================================================
#
# Instructions
# Paste above main.
# Inside of an event page, use $game_map.events[id].remove_page(#), where id is the event id you wish to modify and # is the page on that event.

# Alternate usages:

#   - You may choose to use remove_current_page to remove the currently active page on an event.  (According to find_proper_page)  Eg. $game_map.events[id].remove_current_page

#   - You may also choose to simply use the code segment 'remove_current_page' from the script of an event to remove the currently active page of the event you are on.

#   - There are aliases for each of the methods, as well, if you are running out of space in your script block, but they shouldn't be needed.
#
#===============================================================================
#
# Free for any use as long as I'm credited.
#
class Game_Event < Game_Character
  def remove_current_page
    @event.pages.delete(@page)
    refresh
  end
 
  def remove_page(id)
    @event.pages.delete_at(id - 1)
    refresh
  end
  alias_method :rm_cur_page, :remove_current_page
  alias_method :rm_page, :remove_page
end

class Game_Interpreter
  def remove_current_page
    $game_map.events[event_id].remove_current_page
  end
  alias_method :rm_cur_page, :remove_current_page
end
FAQ
None right now.

Credit and Thanks
- Khale_Kitha & Mithran
Version Notes:

1.0.1 - Added the ability to remove the current page of a referenced event.

         - Added the ability for an event page to remove itself.

         - Added space-saving aliases for the methods if script space is an issue.
I'm going to approve this because I am a sucker for simple solutions/time savers, so I love the idea behind this, it is extremely lightweight and has the potential to save on a having to track either a bunch of extra events or switches.  However, I do have an issue with the execution - the method you are using to remove the pages also shifts the indexes of any subsequent pages (eg., delete page 1 before page 2 and page 2 is now actually referenced as page 1; delete page 2 first and 1 is still 1, but 3 would now be 2).  If the only way you can refer to the pages is by index numbers, the indexes themselves should preferably remain fixed.

Also, I'd like to suggest adding a shorter script call or some shortcuts, eg. delete the current page of this event with a single, no argument command to improve accessibility.

Looking forward to see what you do with this in your tutorial  👍
Thanks - have only been using RPG Maker for a few days and was trying to work on how to get something accomplished and the ability to remove a page like this was the only way I could find to elegantly accomplish it.  Generally speaking, it would be used to remove the last page of an event, but I see your point.  I'll think on that. 🙂

Edit:

Added a few modifications.
I have seen your tutorial. You don't need a script to do what you're trying to do there. If you post a question in the VX Ace Support thread, you will get a much better, and easier way of doing it.
To address Mithran's concern about deletion, I would consider simply flagging the page so the event knows it's disabled and will not choose that page (until re-entering the map, or possibly some other condition such as time elapse, other script calls, etc)
I have seen your tutorial. You don't need a script to do what you're trying to do there. If you post a question in the VX Ace Support thread, you will get a much better, and easier way of doing it.
So far, I've been researching this on several sites and no one has given a decent response when someone asks how to go about it.  Their responses are always to use switches or variables which, to me, is an unacceptable solution.   If you know of anything particular that I've not been able to find, I wouldn't mind a PM regarding it, though.
Sure - I'll send you something.

Original thread: https://forums.rpgmakerweb.com/threads/temporarily-remove-a-page-from-an-event.15457/