Switch Swap [Snippet]
#1
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
end

Instructions
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.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Name Game Switch & Variable VX + ACE kyonides 0 77 10-28-2024, 01:39 AM
Last Post: kyonides
   Weapons Swap VX + ACE kyonides 1 172 09-27-2024, 07:41 AM
Last Post: kyonides
   Switch Tags kyonides 1 1,197 01-08-2024, 03:48 AM
Last Post: kyonides
   [split] Variable Swap [Snippet] PK8 0 134 11-15-2009, 08:49 PM
Last Post: PK8



Users browsing this thread: 1 Guest(s)