This Script will allow you to Check and Change Self Swtiches from ANY Event on your current Game Map.

Minor Limitations:

It doesnt do anything in Battle or across different Maps. If you need to check a Switch across Game Maps or in Battle, you'll be better off using a Game Switch instead of a Self Switch. I've found that most of the Switch Calls that I've needed are done per Event, and almost always on the same Map, so Self Switches does the trick much "cleaner" in most cases, but yes, I still do use Game Switches as well.

NOTE:

The standard Set Move Route does allow for changing a Game Switch from within a Move Route, but there is nothing in there for changing a Self Switch. You aren't limited to only changing an Events own Self Switches either as ALL Events on a Map can be simply accessed by their Event ID.

The Event ID in Arguments will default to self.id if an Event ID is not specified. That is useful for copying and pasting events where your Event ID will be an unknown quantity.Features

#==============================================================================## HERETIC'S CONTROL SELF SWITCHES ANYWHERE# Version 1.0# Monday, September 9th, 2013##==============================================================================## The Default Game Engine allows you to change Game Switches from a Move Route# but does NOT have anything to allow you to change Self Switches. This# script will allow you to Check and Change ANY Self Switches for Any Event# on your Current Map.## * get_self_switch( Letter, event_id)# - Letter is 'A', 'B', 'C', or 'D', WITH Quotes, Upper case doesnt matter# - Returns True if Switch is ON# - Returns False if Switch is OFF# * set_self_switch( Letter, On or Off, event_id)# - Letter is 'A', 'B', 'C', or 'D', WITH Quotes, Upper case doesnt matter# - Sets Switch Letter to Value (true or false, 'On' and 'Off' okay too)## The intent of this script is to save you from always having to use# Game Switches by allowing you more access to Self Switches. Too# many Game Switches can make your game excessively comples for things# that will most likely only relate to Events on One Map. If you need# to check Switches across Game Maps or during Battle, then the use of# Game Switches is a better idea.## NOTE: The script calls in Event -> Script and Move Route -> Script are# quite similar, but not exactly the same. It may be easiest for you to# use this script by calling ALL of the arguments.## get_self_switch can use TWO Arguments# set_self_switch can use THREE Arguments## If you have any difficulty with the Script Calls, just use all arguments# and that will usually solve your problems. I tried to set up this script# to provide lots of error messages that clearly explain what went wrong# should something go wrong in your script call.## NOTE: I allowed for the usage of get_self_switch inside of Set Move Route# because you can use a Ternary Operator for Conditional Move Routes. It is# very unlikely that you'll ever need to use get_self_switch inside of # Set Move Route -> Script.## NOTE: You can set a Self Switch for ANY Event on your Game Map, even from# setting a Player Move Route -> Script. When using Player, you MUST call# for an Event ID as the Game Player has no Self Switches. This may be# much easier than jumping in and out of Set Move Route when trying to# synchronize movements.## Installation## Put anywhere between the Default Scripts and Main. These are all unique# definitions so this script should be perfectly compatible with ALL other# scripts in existence.## --- Limitations ---## You cant use during either Battle or Different Maps.## --- Usage ---## You can use anywhere you can make a Script Call, except in Battle.## For Conditional Branching, in Events Page 1, click on Conditional Branch.# Then in Page 4 of the Conditional Branch, go to Script.# In Script, enter "get_self_switch(Letter, event_id) == true / false"# - Dont use Quotes on the whole statement# - Dont use the word IF# - (Letter is 'A', 'B', 'C', or 'D') WITH Quotes in the Script Call.# - Event ID does NOT have Quotes.## Dont forget you CAN PRINT anywhere you can enter a Script Call also.# print get_self_switch(Letter, event_id)##==============================================================================

# Valid Values value_valid = [true, false, 0, 1, 'on','off'] if value.is_a?(String) value = true if value.to_s.downcase == 'on' value = false if value.to_s.downcase == 'off' elsif value.is_a?(Integer) value = true if value == 1 value = false if value == 0 end # If we have A, B, C, or D, and the Event exists if ch.is_a?(String) and "ABCD".include?(ch.upcase) and (value == true or value == false) and $game_map.events[id] # If event ID is valid if @id > 0 and # Make Upper Case for Key ch = ch.to_s.upcase # Make a self switch key key = [$game_map.map_id, id, ch] # Change self switches $game_self_switches[key] = value end # Refresh map $game_map.need_refresh = true # Continue return true else if $DEBUG print "Warning: set_self_switch expects Two Arguments\n", "The First Argument should be the letter A, B, C, or D\n", "The Second Argument should be either True or False.\n", "(On or Off is acceptable too. Just need you", "to say what you want to set it to.)\n\n", "Example: set_self_switch('A',true)\n\n", "Example 2: set_self_switch('A','On')\n\n", "There is an Optional 3rd Argument for", "specifying an Event ID\n\n", "Example 2: set_self_switch('B',false, 32)\n\n", "This Script call to get_self_switch was made\n", "from MOVE ROUTE => SCRIPT\n\n", "set_self_switch in MOVE ROUTES => SCRIPT expect TWO Arguments, THIRD Optional\n", "set_self_switch in EVENT => SCRIPT expects THREE Arguments\n\n", "Your Script: Move Route -> Script set_self_switch('",ch,"','",value,"','",id,"')" if not $game_map.events[id] print "The Event ID: ", id, " you specified\n", "doesn't exist on this map" end end end end #-------------------------------------------------------------------------- # * Get Self Switch(ch, id) # ch : A, B, C, or D # id : Event ID # # - Returns True if a Switch is ON, False if Switch is OFF # - This is usually only good with Ternary Operator but I included it anyway # Example: @direction = (get_self_switch('A',15) ? 8 : 2 #-------------------------------------------------------------------------- def get_self_switch(ch, id = @id) # if Player Move Route and id is not Specified if id == 0 and $DEBUG # Print Error print "When using get_self_switch for Player Set Move Route, you need to\n", "specify an Event ID because the Game Player does not\n", "have any Self Switches\n\n", "Calling in Player with no ID argument causes\n", "the ID to be set to 0" end # If we have A, B, C, or D, and the Event exists if ch.is_a?(String) and "ABCD".include?(ch.upcase) and id and $game_map.events[id] # Make a Key key = [$game_map.map_id, id, ch.upcase] return $game_self_switches[key] else if $DEBUG print "Warning: get_self_switch expects Two Arguments\n", "The First Argument should be the Letter of\n", " the Self Switch you are Checking, A, B, C, or D\n", "The Second Argument should be the Event's ID\n",

Should be 100% compatible with all other scripts out there as the definitions should be unique.Credits and Thanks

I'd like to thank the academy.

Author's Notes

I want to make this compatible with VX and VXA, but dont know if the Class names are different. Yeah, I know, still never bought VX (probably never going to) or VXA. I'll post different versions for each just so they're compatible, or one if the Class names in VX and Ace are the same.

This script probably wont be useful to experienced scripters. It may still have a small value in keeping syntax short and readable instead of one lining key | value pairs, as well as the error messages.

I wrote this a long time ago, in a rather sloppy way. After doing some heavy Mapping, Eventing, and Scripting recently, I realized how much I actually rely on this script. Thus if I use it for other stuff as much as I apparently am, it will probably be VERY useful to others. So I cleaned it up and decided to share.

So VX and Ace both use Window_ActorCommand, or just VX? I was pretty sure they both named Interpreter something else. Now I know its Game_Interpreter. Thanks for the heads up on that.

I only put a limit on the Self Switches due to Enterbrains limits of the 4 Self Switches on ther Event Page Condition Interface. The Unlimited Self Switches didnt cross my mind. Have to take a peek at it before I give a revision here.

The values are just strings, you can use anything for the switch value. I have created multiple self-switch scripts in the past, basically just have it check for values dynamically instead of being confined to just ['A', 'B', 'C', 'D'].

Obviously those are the only things that can be set via the editor, but if you are changing them using script calls, you can use 'blah_blah_blah' for a switch name and it would work the same.

Logged

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.