VXAce Looking for a 'global self switch resetter' script

I know this is probably a super niche request so it wouldn't surprise me if it hasn't been done, but I figured I'd shoot my shot regardless.

I've been looking for a script to reset my game mid-playthrough, ideally only resetting all of the self switches. What I'm looking to have happen is, for example, if the player gets a game over while playing on the game's hardest difficulty, the game resets to a specific moment near the start, basically a sort of 'time loop' system. I've managed to reset everything like the switches and variables, but self switches remain flipped, so any items the player had picked up won't reappear when they should. I know I could just forgo self switches entirely and make a normal switch for every instance instead, but I figured I'd ask on the off-chance something like a self switch resetter had already been made or was otherwise feasible to write up.
Hello, self switches are handled by $game_self_switches
So a line like this:
Ruby:
$game_self_switches = Game_SelfSwitches.new
should reset all of them.
Hello, self switches are handled by $game_self_switches
So a line like this:
Ruby:
$game_self_switches = Game_SelfSwitches.new
should reset all of them.
Thanks so much, I'll try that! I already tried using just Game_SelfSwitches.new, I didn't think to put that first part in front of it.

Edit: Yep, it works! I should note that if any self switches are on the map where you call the script, they won't be reset until you leave the map and return. Thanks again!
I already tried using just Game_SelfSwitches.new, I didn't think to put that first part in front of it.
That's because Game_SelfSwitches.new is like saying 'Here is a new thing that can deal with self switches' but it doesn't do much if you don't put it at the right place.
So $game_self_switches = Game_SelfSwitches.new is like saying 'the object dealing with self switches is now a new thing that can deal with self switches'.

Edit: Yep, it works! I should note that if any self switches are on the map where you call the script, they won't be reset until you leave the map and return. Thanks again!
Oh I forgot this part, I wonder how you reset your switches and variables since you could get a similar issue. Anyway, if you do something like this:
Ruby:
$game_self_switches = Game_SelfSwitches.new
$game_map.need_refresh = true
Your events should reset properly ~
I should add that if you've deleted or moved events with events calls in your map then you will have to leave and return to the map anyway if you want them back.

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-a-global-self-switch-resetter-script.180653/