View Full Version : [Essentials Script] Setting Self Switch in one map from another map

Derxwna Kapsyla
March 10th, 2013, 7:06 AM
The current version of pbSetSelfSwitch is a really good addition to Pokemon Essentials, as it allows you to remotely set the self switch of an event. This nullifies the need to make another global switch which only effects 1 solitary event. The only downside to it was that it only worked locally, within the same map. Sometimes, you needed an event which did something, but only after you were many maps away, and would be solved much easier with a Self Switch than a Global Switch, as it would only effect that one event. Not to mention, RPG Maker XP has a limit of 999 Global Switches, and after that you can't create anymore. If you have your entire Global Switches filled up with switches that effect one event and only one event, on a repetitive basis, you'll eventually find yourself running short on space for switches when you need them.
While I was messing around with RPG Maker VX Ace, I found a script that allowed you set the Self Switch of an event from anywhere to any event across the game. This was a much useful, and I had asked my friend if he could figure out how to reverse-engineer (if that's the right term) the script so it would would in RPG Maker XP. Fortunately, the process was so simple that reverse-engineering wasn't really needed.
# Sets another event's self switch (eg. pbSetSelfSwitch(20,"A",true) ).
# To be used in a script event command.
def pbSetSelfSwitch(event,swtch,value)
$game_map.need_refresh = true
The above script is the original script, the one used to set Self Switches across the map its in.
def pbSetSelfSwitch2(map,event,swtch,value)
$game_map.need_refresh = true
This script changes @map_id so that it's an actual variable and not dependent on the map you're currently on. This script, however, cannot replace the original one, as it will break areas where you've currently used pbSetSelfSwitch. The script has been tested, and is shown to remain in effect even after you leave the maps where the event was set and the map where the set event was. The script should be placed below the original, in the PokemonMessages script section, around Line 364.

Hopefully you find a use for this script, I know it's going to be useful to me.
If used, you should probably give credit to Mugendai/DoctorInfinity for this, as he's the one who modified it to work across the game.
Maruno why wasn't this in Essentials by default?

Black Eternity
April 7th, 2013, 8:40 PM
Thank you for sharing this!
One thing you should note, "for beginners", to actually use it in an event...

Map ID = Going to map list on the side, right click and select "Map Properties" (ID:###)
Event ID = When editing event you will also see "ID:###"
Switch = "A,B,C,D"
True/False = .............

an full example:

Also, make sure not to place these events too close to the edge of the map,
as it will not be refreshed until upon entering the map. (Can still see the event from other map)

Just trying to make it easier. I am a noob. :P

April 14th, 2013, 4:52 AM
Nice script yo gonna surely use it.

It will solve most of my problem ^.^

October 30th, 2015, 9:15 PM
I know this threads old but I putting this here because you don't need to add this script all you need to do in an event in a script box just put

$game_self_switches[[MAP ID,EVENT ID,"The Switch"]]=Value(i.e. true or false)


Derxwna Kapsyla
October 31st, 2015, 11:17 PM
You could also do that with regular self switches, but the script makes for a much cleaner, and a much more manageable and easy to parse method.