Make every event on map dissapear.

So, I'm working on an easter egg for my RPG Maker Project, and I want to know how to do something in script calls...


How can I make every event on the map disappear (as if they were erased) and disable saving using a single script call?


Also, one optional thing:


I also want to change the title bar displaying the name of the game to a specific string.
You could just make an event page with nothing on it on the events you want to disappear and have it be triggered by a switch in the conditions tab.
You could just make an event page with nothing on it on the events you want to disappear and have it be triggered by a switch in the conditions tab.

Yeah. But, due to the easter egg I want, that would mean I'd have to program new events to do that too. I also want every event to disappear, leaving just the player and the tiles.


Figured it out:

Code:
for (var i = 1; i < $gameMap.events().length; i++) {
  $gameMap.eraseEvent([i]);
};
$gameSystem.disableSave();
Congrats


s9bPVaK.gif
Yeah, there are several ways. I was going to suggest the following, but your method is fine, too.

Code:
$gameMap._events.forEach(function(event) {
  event.erase();
});

$gameSystem.disableSave();
Yeah, there are several ways. I was going to suggest the following, but your method is fine, too.



$gameMap._events.forEach(function(event) {
event.erase();
});

$gameSystem.disableSave();

Yeah, that works better.


My method didn't do it with the last event.
You just needed to do the following :  $gameMap.events().length - 1

'length' starts the count at 1 while the '_events' array starts at 0.
You just needed to do the following :  $gameMap.events().length - 1

'length' starts the count at 1 while the '_events' array starts at 0.

Oh, got it.


Now, is there any way to make the game print an error (show RPG Maker MV's error screen with a custom "error") after about 30 seconds since that script was activated, while giving the player the option to move around until the crash?


And, is it possible to change the title bar text?
Oh, got it.


Now, is there any way to make the game print an error (show RPG Maker MV's error screen with a custom "error") after about 30 seconds since that script was activated, while giving the player the option to move around until the crash?


And, is it possible to change the title bar text?

I'm pretty sure you have to use the SetWindowText() Command.
I'm pretty sure you have to use the SetWindowText() Command.

ok
You can create an error using the following :


throw new Error('Error text');


Not quite sure how to change the name of the game window, and I'm too short of time to poke around.
You just needed to do the following :  $gameMap.events().length - 1

'length' starts the count at 1 while the '_events' array starts at 0.

Also, what if I want to exclude an event with a certain ID from being removed?


Sorry moderators, I know double posting isn't allowed but I had already made the previous post and was unsure how to add a quote to it as it would add it to the new post box.
You just needed to do the following :  $gameMap.events().length - 1

'length' starts the count at 1 while the '_events' array starts at 0.

Also, what if I want to exclude an event with a certain ID from being removed?


Sorry moderators, I know double posting isn't allowed but I had already made the previous post and was unsure how to add a quote to it as it would add it to the new post box.


(Whoops, I refreshed because it didn't appear to be posting, and it posted twice. Sorry, I have bad internet.)
Code:
$gameMap._events.forEach(function(event) {
  // If not the 1st event, erase event ...
  if (event._eventId != 1) event.erase();
  
  // If you want to select separate actions for
  // different events ... 
  switch (event._eventId) {
    // When event._eventId equals 1 ...
    case 1:
      // [code to execute]
      break;
      // When event._eventId equals 3 ...
    case 3:
      // [code to execute]
      break;
    // Everything else ...
    default:
      event.erase();
      break;
  }
});

$gameSystem.disableSave();

Original thread: https://forums.rpgmakerweb.com/threads/make-every-event-on-map-dissapear.66087/