Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 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 RG kyonides 0 522 06-27-2023, 09:17 PM
Last Post: kyonides
   Weapons Swap kyonides 1 798 01-15-2023, 04:56 AM
Last Post: kyonides
   Variable Extraction Generator DerVVulfman 0 2,460 07-20-2020, 06:58 PM
Last Post: DerVVulfman
   DoubleX RMVXA Variable Pointers DoubleX 0 3,597 06-01-2015, 03:45 PM
Last Post: DoubleX
   Tileset Swap ccoa 4 10,527 04-15-2014, 04:18 AM
Last Post: DerVVulfman
   Variable-Based Battle Themes v1.1 PK8 2 6,489 11-27-2009, 07:29 PM
Last Post: explocion200
   Switch Swap [Snippet] PK8 0 4,118 11-09-2009, 07:07 AM
Last Post: PK8
   Variable-Based Battle Victory MEs PK8 4 6,970 09-29-2009, 12:58 PM
Last Post: Alpha-Mad
   Global Variable Standard Check Yeyinde 0 4,035 12-07-2008, 12:03 PM
Last Post: Yeyinde
   Variable Image Menu Mac 0 4,527 03-08-2008, 01:09 AM
Last Post: Mac



Users browsing this thread: