Save-Point
Script switch management - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Archives (https://www.save-point.org/forum-105.html)
+--- Forum: Creation Asylum Archives (https://www.save-point.org/forum-90.html)
+---- Forum: Scripts & Code Snippets (https://www.save-point.org/forum-92.html)
+----- Forum: RPG Maker XP Code (https://www.save-point.org/forum-93.html)
+------ Forum: Enhancement/Modification Scripts (https://www.save-point.org/forum-98.html)
+------ Thread: Script switch management (/thread-6568.html)



Script switch management - GubiD - 08-19-2007

Script switch management
by GubiD
Aug 19, 2007

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given.


This is so you can flip exiting switches or self switches with script to make it easier for some mapping situations.

Code:
class Game_Map
  def switches(id = 0, value = false, type = 0, switch = "A")
    if id > 0
      if type == 0 #for use of main switches
        #id is switch_id and value should set to true or false
        $game_switches[id] = value
      elsif type == 1 #For use of self switches
        #id is event.id and switch is the desired selfswitch.  It must be text!
        #value is true or false
        key = [$game_map.map_id, id, switch]
        # Updates self switch
        $game_self_switches[key] = value
      end
      # Refresh map
      $game_map.need_refresh = true
      return true
    end
  end
end


You can call the script by doing the following...

To true a switch, $game_map.switches(switch_id, true) to false $game_map.switches(switch_id)

To true a self switch $game_map.switches(1, true, 1, "B"), to false it $game_map.switches(event_id, false, 1, "B")
The "B" is the desired self switch. The self switch must be text so be sure to use "A" or whatever switch you want.


If there are any problems with the script let me know.