DL: Self Switch Reset

SelfSwitch.png

Script: Self Switch Reset
Difficulty: Easy
Short Version: Reset an Event's Self Switches when changing maps.
Spoiler: Script
Code:
#--------------------------------#
# Dramatic Lightning Co Presents:
# Self Switch Reseter
#--------------------------------#
# You can reset your Event's Self Switches with this script!
# Create a Comment in the first line of your Event page and
# place <resetss: 0abcd> there.  abcd are the letters of the
# self switch you want to reset.
#--------------------------------#
# By default, you only need to place the notetag in the first
# page and it'll reset the self switches regardless of what
# page you're on.  You can put 0 (zero) in the notetag so that it'll
# only affect the first page.  Alternatively, you can place the
# notetags in each other page.
#--------------------------------#


module DL
  module Renew
   Regex = /<resetss:\s*(\w+)\s*>/i
  end
end

module RPG
  class Event::Page

   def reset_ss
     bob = ""
     @list.each {|cmd|
       if cmd.code == 108 && res = cmd.parameters[0].match(DL::Renew::Regex)
         bob = res[1].to_s
       end
     }
     return bob
   end
  end
end

class Game_Event < Game_Character
  alias dl_renew_initialize initialize
  def initialize(map_id, event)
   dl_renew_initialize(map_id, event)
   renew_self(map_id, event)
   refresh
  end

   def renew_self(map_id, event)
     bob = ""
     bob = @event.pages[0].reset_ss  if @event.pages[0]
     bob = @page.reset_ss if bob == "" or bob.include? "0"
    
     $game_self_switches[[map_id, event.id, "A"]] = false if bob.include? "a"
     $game_self_switches[[map_id, event.id, "B"]] = false if bob.include? "b"
     $game_self_switches[[map_id, event.id, "C"]] = false if bob.include? "c"
     $game_self_switches[[map_id, event.id, "D"]] = false if bob.include? "d"
   end
  
end

---

So pretty much the idea for this script came from thinking: if I give an Event a "Status Effect" A that turns him into an old man, I don't want to leave that old A on when I come back. So what this small script does is reset a few Self Switches whenever you reload a map. For this script, you place the

<resetss: 0abcd>

in a Comment, and you place that Comment in the first line of the Event Page. The letters in the string each represent a Self Switch, so if you want to turn off Self Switch A and C, you put down <resetss: ac>

You can put the notetag in any page so that they'll only affect that page, but you can also put the notetag in the first page to affect ALL the pages. However, if you want that notetag to affect only the first page, you'll have to add 0 (zero) into the string.

Original thread: https://forums.rpgmakerweb.com/threads/dl-self-switch-reset.85861/