[split] Variable Swap [Snippet]
#1
Variable Swap Snippet

Introduction
This snippet swaps the values of two game variable you specify in a command.

Features
  • Swaps values of Game Variables via command.

Screenshots
No screenshot.

Demo
No demo.

Script
Code:
=begin
????????????????????????????????????????????????????????????????????????????????
? Variable 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 variables you specify in a command.     ?
????????????????????????????????????????????????????????????????????????????????
? ? Features                                                                   ?
? ? Swap values of two variables with a script call.                           ?
????????????????????????????????????????????????????????????????????????????????
? ? How to Use                                                                 ?
?   Call script: variable_swap(from, to)                                       ?
?     from: Original variable. | to: Variable it's swapping with.              ?
?                                                                              ?
?   Example: Variable ID 1 = 45, Variable ID 5 = 90.                           ?
?       call: variable_swap(1, 5)                                              ?
?     The values of the two variables would swap, which means, going back to   ?
?     the example above, Variable ID 1 would equal 90 and Variable ID 5 would  ?
?     equal 45.                                                                ?
????????????????????????????????????????????????????????????????????????????????
=end

#==============================================================================
# IMPORTANT! RMVX users, set this to false!
#==============================================================================
class PK8
  Variable_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::Variable_Swap_RMXP == true
  class Interpreter
    def variable_swap(from, to)
      fromtemp = $game_variables[from]
      totemp = $game_variables[to]
      $game_variables[from] = totemp
      $game_variables[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::Variable_Swap_RMXP == false
  class Game_Interpreter
    def variable_swap(from, to)
      fromtemp = $game_variables[from]
      totemp = $game_variables[to]
      $game_variables[from] = totemp
      $game_variables[to] = fromtemp
      return
    end
  end
end

Instructions
If you're using RMVX, set "Variable_Swap_RMXP" to false. To use it, just call script:
Code:
variable_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 138 10-28-2024, 01:39 AM
Last Post: kyonides
   Weapons Swap VX + ACE kyonides 1 262 09-27-2024, 07:41 AM
Last Post: kyonides
   DoubleX RMVXA Variable Pointers DoubleX 0 4,258 06-01-2015, 03:45 PM
Last Post: DoubleX
   Variable-Based Battle Themes v1.1 PK8 0 251 11-24-2009, 11:35 PM
Last Post: PK8
   Switch Swap [Snippet] PK8 0 227 11-14-2009, 05:23 AM
Last Post: PK8



Users browsing this thread: 1 Guest(s)