Permanently Erase Events With One Event Command

curioushika

Veteran
Veteran
Joined
Dec 14, 2017
Messages
63
Reaction score
9
First Language
Not-English
Primarily Uses
RMMV
I've been wondering, is it possible to erase events with just one event command?

Currently, the way I permanently erase events is by creating a blank page with erase event command in that event with a set switch. And if that switch is turned on, the event then will permanently deleted. (AFAIK)
However, I reckon by doing so will leave me with a tons of switches to manage in the future. So, I'm hoping for any methods that are more practical if possible.

Thank you very much for your help :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,107
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
I think there are other things that affect the performance of your program far more than a simple switch or self switch.

No event is permanently deleted. Every event is loaded when the map is loaded. Then if you have some set to erase self, they will be deleted. You don't have to "manage" a switch. The program already manages them for you.

My suggestion is to put your efforts into other more significant things.
 

mathmaster74

just...John
Veteran
Joined
Jun 12, 2016
Messages
285
Reaction score
193
First Language
English
Primarily Uses
RMMV
@curioushika At the end of the second to last page of the event to be "erased", set Self Switch D (unless you already used it, in which case, you make a new switch). Make the last page of the event require Self Switch D (or the switch you made), and leave it blank. The event will technically always be there, but never run again. No new switches need be created unless you've gone through all Self Switches. What Shaz said is correct:

No event is permanently deleted. Every event is loaded when the map is loaded. Then if you have some set to erase self, they will be
[temporarily]
[until the map loads again...]
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,107
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
leaving the event there like that will still cause it to be checked every time the map needs a refresh, to see if the same page should be active. It will also cause the event's location to be checked every time the player, or another event, moves from one tile to another. So there's an overhead in keeping it around, even though it's not "doing" anything.

Setting it to parallel process with Erase Event will cause a little extra processing when the map first loads, but the event will not be checked again until the map is reloaded.
 

curioushika

Veteran
Veteran
Joined
Dec 14, 2017
Messages
63
Reaction score
9
First Language
Not-English
Primarily Uses
RMMV
I'm sorry that I didn't made the post clearly. I understand that an event can't be literally permanently erased, which is why I used this method at the moment.

The method that I use is quite similar with what @mathmaster74 suggested. For example:
I made a cutscene which involves Event A, B and C. Event A is what trigger & control the cutscene. After the said cutscene done, I want to erase all of the events. Erasing Event A is simple by using self-switch and then create a second page that uses command Erase Event with Autorun. But AFAIK, to erase event B & C, I have to create and turn on a new switch (which I meant by "manage") in both events.

The problem with this method is, every time I want to erase an event, I have to create & turn on new switch. If I want to delete event B & C one by one, I have to make 2 switches, which means there will be 2 switches per event. I reckon the number will increase exponentially because I intend to make quite a lot of cutscenes.

tl;dr What I want really want to ask is, is there any way to trigger self-switch by just 1 event command? I believe it's unlikely, so any suggestions to "erase" event efficiently are welcome.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,107
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
You can turn on one event's self switch from another event. Just use the Outer Self Switches plugin, which I believe ships with the engine (if not in the default plugins for a new project, possibly in the DLC), or do it directly in a script command. If your map is 15, and your cutscene event is 8, and you want to turn on self switch A for events 9 and 10, just do this:
Code:
$gameSelfSwitches.setValue([16, 9, 'A'], true);
$gameSelfSwitches.setValue([16, 10, 'A'], true);
And use a parallel process trigger, not an autorun. Only one autorun can run at a time, but several parallel process events can run at the same time. The way you're doing it, you could be in a situation where you have a REAL cutscene that needs to play when you enter a map, and 3 events that delete themselves, and the 3 events won't delete themselves until after the cutscene has finished.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,418
Reaction score
7,709
First Language
German
Primarily Uses
RMMV
and why do you even want to erase those events?

Events alone, especially events that do nothing, have only minimal effect on a game. It doesn't matter for the performance if there are one or two dozen events around.
In fact you're creating more problems and losses with your insistence on deleting those events than they could ever cause by themselves.

Yes, there are some cases where events are better deleted - but that is such a low number that the number of switches for it doesn't matter for the game.

So I'm wondering on why you think you need to do this.
 

curioushika

Veteran
Veteran
Joined
Dec 14, 2017
Messages
63
Reaction score
9
First Language
Not-English
Primarily Uses
RMMV
@Shaz Thank you so much. :) That looks quite like what I want, and the plugin is already included indeed, so I will check it soon.

@Andar That's true, but I need this to tidying up the map after a cutscene that happens in that particular map ends.
For example:

https://i.imgur.com/yKyMqAN.png

In that picture there are 6 events that involved in a cutscene, and they're not doing anything indeed, but if I don't erase it, they will still linger in there even after the player re-enter the map, which will make it look awkward.
Most tutorials that I have watched only show how to make the cutscenes, but not tidying up afterwards, so this is the only way that I can think of at the moment.
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
Here a few more examples of that Codeline for self switch.

Current Map, Self Event, A ,On
$gameSelfSwitches.setValue([$gameMap.mapId(), this._eventId, 'A'], true)

Current Map, Event 5, A, On
$gameSelfSwitches.setValue([$gameMap.mapId(), 5, 'A'], true)

You could also specifie the Event Id by a Variable
$gameSelfSwitches.setValue([$gameMap.mapId(), $gameVariables.value(1), 'A'], true)

Edit:
In the Scriptcall list is also the command for erasing event ids.
but the problem is after mapreload they would be back, so the solution with extra eventpage is good i think.

$gameMap.eraseEvent(this._eventId);
$gameMap.eraseEvent(5);
$gameMap.eraseEvent(12);

https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-script-call-list.46456/

Edit2:
I would not erase them, just turn on there last eventpage with self switch command and dont forget to mark the "through", else other events cant move over them.
Best solution even if the map reloads. But i agree using a extra switch for every event would be overkill =).
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,418
Reaction score
7,709
First Language
German
Primarily Uses
RMMV
but not tidying up afterwards, so this is the only way that I can think of at the moment.
Those events are usually switched off to a page that has no sprite and is at above priority (or through as said above), no need to erase them.
Another trick would be to condition them to the cutscene - that would be one switch for the total group of events.
Just make one switch "cutscene active" and condition all their event pages (or their only page if they don't need anything else) to that switch. If no page is active then the events will also vanish, so a switch like that will only make them appear if that switch is ON, and you do that only when the cutscene needs them.
 

curioushika

Veteran
Veteran
Joined
Dec 14, 2017
Messages
63
Reaction score
9
First Language
Not-English
Primarily Uses
RMMV
@Bex I see. Thanks for the suggestion :cutesmile:

@Andar Tying all the events to one switch seems the most efficient idea I've heard so far. Although I think it'd be a problem if there are multiple events that appear and gone in the same area in the map. For example if I want to remove event A first and event B afterwards, and both events are in the same map, if I turn the Event Switch off, both of them will be gone at the same time instead of one at a time.
But I think I'm going to try this for the time being. Thank you so much :cutesmile:
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,418
Reaction score
7,709
First Language
German
Primarily Uses
RMMV
For example if I want to remove event A first and event B afterwards, and both events are in the same map, if I turn the Event Switch off, both of them will be gone at the same time instead of one at a time.
a page has more conditions than one.
you can use a second switch condition for fine control of those events that will appear later, and they would still all vanish if you switch off the main switch because both switches need to be on if two switches are in the condition.

and a lot of people also use variables for fine control of larger segments, like a story step - each time the story proceeds the counter goes up and several things throughout the entire game will react to that counter variable and only happen if the player has progressed to that step of the story.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,528
Reaction score
14,259
First Language
English
Primarily Uses
RMVXA
You could do what I do...I set aside switches 21 - 30 for cutscene control, and named them Scene I - X. Scene I is for the party members that need to be there for the cutscene, and I use Scene II and onwards if I need something to appear for a 2nd scene in the same area. Has worked really well, and in the end I never went past Scene IV.

Also for really long plot cutscenes I just transfer the player to a cutscene map that is used just for the cutscene. The player will not know the difference.
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,530
Reaction score
1,423
First Language
English
Primarily Uses
RMMV
If you don't want events to load in return trips to the map after a cutscene, you could always use something like Yanfly's event spawner. Since they're spawned via function calls during the cutscene, they're not part of the permanent map data and will not reappear afterward. Now I don't know how well the whole thing works because honestly, this level of optimization just isn't necessary, but you could try it and see if it's what you're looking for.
 

p0_boy

anti-kumbaya
Veteran
Joined
Mar 26, 2019
Messages
64
Reaction score
29
First Language
English
Primarily Uses
RMMV
@curioushika - At the risk of getting somebody angry, might I suggest killEvents.js?

To use it, just make a script call (replace event_id as neccessary):

Code:
pagpatay.an.killEvent(event_id);
e.g.
Code:
pagpatay.an.killEvent(1);
Deleted events are retained by save files.

I hope this helps :)
 

curioushika

Veteran
Veteran
Joined
Dec 14, 2017
Messages
63
Reaction score
9
First Language
Not-English
Primarily Uses
RMMV
@Andar Thank you so much. This seems quite practical :)

@bgillisp Transferring the player into a cutscene map is a great idea. Thanks :D

@Aesica Yanfly Event Spawner could be a viable option. Thanks for the suggestion :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect
I have gathered enough feedback from a few selected people. But it is still available if you want to sign up https://forums.rpgmakerweb.com/index.php?threads/looking-for-testers-a-closed-tech-demo.130774/

Forum statistics

Threads
105,992
Messages
1,018,195
Members
137,773
Latest member
Kirakirna
Top