Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 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
   Switch Tags kyonides 1 346 01-08-2024, 03:48 AM
Last Post: kyonides
   Name Game Switch & Variable RG kyonides 0 522 06-27-2023, 09:17 PM
Last Post: kyonides
   Weapons Swap kyonides 1 801 01-15-2023, 04:56 AM
Last Post: kyonides
   Switch Extraction Generator DerVVulfman 1 2,939 06-19-2020, 03:43 AM
Last Post: DerVVulfman
   Tileset Swap ccoa 4 10,528 04-15-2014, 04:18 AM
Last Post: DerVVulfman
   Variable Swap [Snippet] PK8 0 4,143 11-09-2009, 07:32 AM
Last Post: PK8



Users browsing this thread: