11-14-2009, 05:23 AM 
(This post was last modified: 09-03-2024, 03:24 AM by DerVVulfman.)
	
	
	Switch Swap Snippet
Introduction
This snippet swaps the values of two game switches you specify in a command.
Features
- Swaps values of Game Switches via command.
 
Screenshots
No screenshot.
Demo
No demo.
Script
Code:
=begin
????????????????????????????????????????????????????????????????????????????????
? Switch Swap Snippet by PK8, November 9th, 2009.                              ?
? http://rmvxp.com                                                             ?
????????????????????????????????????????????????????????????????????????????????
? ? Table of Contents                                                          ?
? ?? Author's Notes                - Line 12,13                                ?
? ?? Introduction & Description    - Line 15,16                                ?
? ?? Features                      - Line 18,19                                ?
? ?? How to Use                    - Line 21?29                                ?
????????????????????????????????????????????????????????????????????????????????
? ? Author's Notes                                                             ?
? Boredom + running out of ideas = this.                                       ?
????????????????????????????????????????????????????????????????????????????????
? ? Introduction & Description                                                 ?
? This snippet swaps the values of two switches you specify in a command.      ?
????????????????????????????????????????????????????????????????????????????????
? ? Features                                                                   ?
? ? Swap values of two switches with a script call.                            ?
????????????????????????????????????????????????????????????????????????????????
? ? How to Use                                                                 ?
?   Call script: switch_swap(from, to)                                         ?
?     from: Original switch. | to: Switch it's swapping with.                  ?
?                                                                              ?
?   Example: Switch ID 1 is turned on, Switch ID 5 is turned off.              ?
?       call: switch_swap(1, 5)                                                ?
?     The values of the two switches would swap, which means, going back to the?
?     example above, Switch ID 1 would be turned off and Switch ID 5 would be  ?
?     turned on.                                                               ?
????????????????????????????????????????????????????????????????????????????????
=end
#==============================================================================
# IMPORTANT! RMVX users, set this to false!
#==============================================================================
class PK8
  Switch_Swap_RMXP = true # true if using RMXP, false if using RMVX.
end
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  This interpreter runs event commands. This class is used within the
#  Game_System class and the Game_Event class.
#==============================================================================
if PK8::Switch_Swap_RMXP == true
  class Interpreter
    def switch_swap(from, to)
      fromtemp = $game_switches[from]
      totemp = $game_switches[to]
      $game_switches[from] = totemp
      $game_switches[to] = fromtemp
      return
    end
  end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
if PK8::Switch_Swap_RMXP == false
  class Game_Interpreter
    def switch_swap(from, to)
      fromtemp = $game_switches[from]
      totemp = $game_switches[to]
      $game_switches[from] = totemp
      $game_switches[to] = fromtemp
      return
    end
  end
endInstructions
If you're using RMVX, set "Switch_Swap_RMXP" to false. To use it, just call script:
Code:
switch_swap(from, to)FAQ
Awaiting question.
Compatibility
I'm sure it's compatible.
Credits and Thanks
No thanks. :P
Author's Notes
Boredom + running out of ideas = this script.
Terms and Conditions
Credit's not necessary.

 
 
 Switch Swap [Snippet]
 Switch Swap [Snippet]
 

 
