Disable events momentarily

Hi
i want to disable all the player/event touch events (for a moment) but I don't know what is the best way for this?

i was thinking of adding self switch to all the events via script so I don't have to edit any of the events and then toggle that selfswitch. unfortunately I don't know how to do that via script.

first thing i need to check is if the events have touch trigger but i couldn't find this from the code.
i could only find the priority variable =/

any ideas?

thx!
several different possibilities.

1) you can use a move route targeted on the player to make him through ON - that way he will not trigger any event at all, but also ignore all walls and impassibilities.

2) you can use a general switch to a higher event page, that way you only have to use one switch for every event together instead of dozens of script commands

There might be other ways, but unfortunately you don't give enough details on the what and why to be able to check for other options.
So why would you need to identify which events has which trigger to do that? for example the switch needs a specific page anyway, and you have to add that via editor so simply only add it to those events where you want the block to happen.
Rather important clarifying question: do you still want the touch trigger events to be interactable with the action button, or for their interactions to be disabled completely?
There might be other ways, but unfortunately you don't give enough details on the what and why to be able to check for other options.


well I'm working on tactical battle system and I don't want the player to leave the map using transfer event, while the battle is on

I thought self switch would be good as i can toggle that on/off via script but I would also need to enable that (the condition) via script to avoid editing all the events manually
Rather important clarifying question: do you still want the touch trigger events to be interactable with the action button, or for their interactions to be disabled completely?

completely disable while battle is on, then enable them again
Then that should do it I think - if switch 42 is on, player touch and event touch event won't be able to start.
JavaScript:
Game_Player.prototype.startMapEvent = function (x, y, triggers, normal) {
    if (!$gameMap.isEventRunning()) {
        $gameMap.eventsXy(x, y).forEach(function (event) {
            if (event.isTriggerIn(triggers) && event.isNormalPriority() === normal) {
                if(!$gameSwitches.value(42) || !event.isTriggerIn([1,2])) event.start();               
            }
        });
    }
};
that (the condition) via script to avoid editing all the events manually
sorry, but editing all events manually to add the page IS the easiest and fastest way.

theoretically and if it is only the transfer itself that is the problem, then you can request or commission a plugin that installs a switch inside the game interpreter to disable the transfer command. But that only works if there are no other commands in the event, or if those other commands can be ignored, and is still a change that can break a lot of other things.

but adding event pages by script is the ultimate horror, as proven a long time ago.

if switch 42 is on, player touch and event touch event won't be able to start.
That solution does not make any difference between events used for transfer and events used as enemy units. Does the OP really wants to disable the triggers on events used as enemies?
That depends on how his battlesystem handles enemies, but if he is concerned about transfers he must use event triggers from the enemies in his structures.
thx for the replies everyone. i was actually able to implement my original idea.
Here's the code if anyone needs (And please tell me if there's any problems with it 😀 )

Code:
// Loop through all the events
      events.forEach(e => {
   
      let ev = e.event();

      let page = ev.pages[0];

      // Add self switch condition
      page.conditions.selfSwitchCh = "A";
      page.conditions.selfSwitchValid = true;

      // Todo use these
      // if(page.trigger == 1 || page.trigger == 2)

       // Disable for now...
       $gameSelfSwitches.setValue([$gameMap._mapId, e._eventId, 'A'], false);

    });
And please tell me if there's any problems with it
Well, if the event has multiple pages, it will only disable the first one.
If the event already had self-switch A on, doing it this way will make it difficult to turn it back on later.
Event with those commented out conditions, you won't be able to make any touch events that you can interact with during battle.
EDIT: Also, if the page already had a self-switch condition, it will be overwritten, meaning you can never have an event with first page including a self-switch condition.
Not big issues if you're fine with those limitation, but they will restrict what you can do with events in the future.

I'd recommend just using a notetag for events that you don't want to be interactable during battle, and checking the meta property in startMapEvent.
Well, if the event has multiple pages, it will only disable the first one.
If the event already had self-switch A on, doing it this way will make it difficult to turn it back on later.
Event with those commented out conditions, you won't be able to make any touch events that you can interact with during battle.
EDIT: Also, if the page already had a self-switch condition, it will be overwritten, meaning you can never have an event with first page including a self-switch condition.
Not big issues if you're fine with those limitation, but they will restrict what you can do with events in the future.

I'd recommend just using a notetag for events that you don't want to be interactable during battle, and checking the meta property in startMapEvent.

yeah there are those limitations, just need to keep them in mind if I ever need more pages than one
*I* would make it so the transfer event is just one, with a hitbox extension plugin to cover the area needed and set it to be on or off with a global switch instead of a self one, that would cut down transfer events by a chunk 😅

Original thread: https://forums.rpgmakerweb.com/threads/disable-events-momentarily.162831/