As the topic name implies, I have a minigame that utilizes very many self switches (read; stones and objects that may blow up when you run into them) however I would like the player to be able to come back and try their luck at the game again later. Is there a way to easily reset every self switch on a map/maps?
Turning self switches off outside of the event?
RPG Maker VXAce SupportThere's a ton of ways to do it, try to find one that conflicts the least with your other scripts.
There is one way which involves no scripts and is simplicity itself.
Self switches can be turned on and off from another event. So you have one master event which turns everything off when e.g. the player leaves that map. The structure of the script call (tab 3 of the event command menu) is
$game_self_switches[[map id, event id, 'self-switch']] = value
So let us suppose that this is map 087, and event 19 is one of the events where you want to turn self switch A to OFF. The script call would then look like this (note, no leading zeros for the map id).
$game-self-switches[[87, 19, 'A']] = false
Use whichever letter for the self switch you want to change i.e. A, B, C, or D - always inside the quote marks. true turns a switch ON, (note lower case t) and false turns it OFF (again lower case f).
Do that call for each event. I've never tried doing it for a lot of events in the same script call, it might work having all the event ids separated by a comma and possibly a space, but I don't know.
Self switches can be turned on and off from another event. So you have one master event which turns everything off when e.g. the player leaves that map. The structure of the script call (tab 3 of the event command menu) is
$game_self_switches[[map id, event id, 'self-switch']] = value
So let us suppose that this is map 087, and event 19 is one of the events where you want to turn self switch A to OFF. The script call would then look like this (note, no leading zeros for the map id).
$game-self-switches[[87, 19, 'A']] = false
Use whichever letter for the self switch you want to change i.e. A, B, C, or D - always inside the quote marks. true turns a switch ON, (note lower case t) and false turns it OFF (again lower case f).
Do that call for each event. I've never tried doing it for a lot of events in the same script call, it might work having all the event ids separated by a comma and possibly a space, but I don't know.
WOW I didn't know that nice!!
I use it a lot. It is very convenient and saves having to use a ton of control switches just to change e.g. an NPC's dialogue page.
I'm using these script calls:
[1,3,5,8,10].each {|event_id| $game_self_switches[[1, event_id, "A]] = true }
This will turn ON self switches "A" in events with ID: 1,3,5,8 and 10 on map with ID 1.
666.times {|event_id| $game_self_switches[[6, event_id, "A]] = false }
This will turn OFF self switches "A" in first 666 events based on their ID's on map with ID 6.
[1,3,5,8,10].each {|event_id| $game_self_switches[[1, event_id, "A]] = true }
This will turn ON self switches "A" in events with ID: 1,3,5,8 and 10 on map with ID 1.
666.times {|event_id| $game_self_switches[[6, event_id, "A]] = false }
This will turn OFF self switches "A" in first 666 events based on their ID's on map with ID 6.
Original thread: https://forums.rpgmakerweb.com/threads/turning-self-switches-off-outside-of-the-event.44607/