[Resolved] Turn off Self Switch A for all events on selected maps

Started by Juz10_gameguy, July 23, 2016, 03:40:47 pm

Previous topic - Next topic

Juz10_gameguy

Hi, Is it possibly via scripts to turn all self switch A or B etc.. on a certain map off . I am familiar with two self switch scripts such as:

$game_self_switches = Game_SelfSwitches.new which resets all self switches on every map

as well as

$game_self_switches[[ map id, event id, 'self switch']] = 'true/false' which will work for what I want to do, it just will take a long time because I will have to input over 60 event id's for each of the five maps I want to use this script on.

I could even make due with a script that for example turns self switch B off on every map. Is there such a script?

KK20


#===============================================================================
# Set Self-Switches to All Events on Map                           Author: KK20
#------------------------------------------------------------------------------
# Purpose:
#   Sets all events' self-switch(es) on a specific map to either ON or OFF.
#
# How to Use:
#   Script can be placed anywhere above Main.
#   In an event, use a 'Script' event command, and type in
#
#                set_self_switches(MAP_ID, SWITCH, VALUE)
#
# Parameters:
#  MAP_ID => An integer; the map ID you wish to reset the self-switches for.
#            If the value is nil, assumes the current map the player is on.
#  SWITCH => A string or array of strings; the self-switch keys you want to
#            change on all events in the map. If nil, will change all of the
#            default self-switch values (i.e. letters A through E).
#  VALUE  => A boolean; choose to set all self-switches to either ON (true) or
#            OFF (false). The default value is false.
#
# Examples of uses:
#   set_self_switches
#     => Turns all the events' self-switches on the current map to OFF
#   set_self_switches(nil, ['A', 'B'], true)
#     => Turns all the events' self-switches A and B on the current map to ON
#   set_self_switches(3, 'A')
#     => Turns all the events' self-switches A on map #3 to OFF
#   set_self_switches(1)
#     => Turns all the events' self-switches on map #1 to OFF
#
#===============================================================================
class Interpreter
  def set_self_switches(map_id = nil, switch = nil, value = false)
    map_id = $game_map.map_id if map_id.nil?
    switch = ['A','B','C','D','E'] if switch.nil?
    switch = Array(switch)
   
    map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
    map.events.keys.each{|event_id|
      switch.each{|switch_type|
        key = [map_id, event_id, switch_type]
        $game_self_switches[key] = value
      }
    }
    $game_map.need_refresh = ($game_map.map_id == map_id)
  end
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Juz10_gameguy