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 XP kyonides 0 1,077 06-27-2023, 09:17 PM
Last Post: kyonides
   Weapons Swap XP kyonides 1 1,551 01-15-2023, 04:56 AM
Last Post: kyonides
   Switch Extraction Generator DerVVulfman 1 3,695 06-19-2020, 03:43 AM
Last Post: DerVVulfman
   Tileset Swap ccoa 4 11,659 04-15-2014, 04:18 AM
Last Post: DerVVulfman
   Variable Swap [Snippet] PK8 0 4,731 11-09-2009, 07:32 AM
Last Post: PK8



Users browsing this thread: 1 Guest(s)