The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on April 06, 2010, 04:50:20 PM

Title: Extra Self Switches
Post by: modern algebra on April 06, 2010, 04:50:20 PM
Extra Self Switches
Version: 1.0
Author: modern algebra
Date: April 6, 2010

Version History



Description


This is just a wrapper to make it easy to create and control more than four self switches of an event.

Features


Instructions

To control the value of any special self switch, you can use this command:
     control_self_switch ("key", value)
       key : the object that you want to use to identify the self switch you are altering. For the sake of consistency, probably better to use capital letters ("E", "F"), but can be anything, even numbers (1, 2)
       value : The easiest way is to use the symbols, :on or :off. You can also use true, to turn ON, or false, to turn OFF.

To later check what the value of a self switch is, use the code:
     self_switch ("key")
       key : the identifier for that self-switch. See line 17.

That will evaluate as the expression Self Switch Key == ON. If you want to check if it is OFF, simply use the code:
     !self_switch ("key")

Script


Code: [Select]
#==============================================================================
#    Extra Self Switches Wrapper
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: April 6, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#    This is just a simple wrapper for making and checking self switches beyond
#   the default four. They will only be accessible through the script event
#   command and conditional branch Script field, however. They will not be able
#   to be controlled through the Control Self Switch event command, or as page
#   conditions
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    To control the value of any special self switch, you can use this command:
#      control_self_switch ("key", value)
#        key : the object that you want to use to identify the self switch you
#          are altering. For the sake of consistency, probably better to use
#          capital letters ("E", "F"), but can be anything, even numbers (1, 2)
#        value : The easiest way is to use the symbols, :on or :off. You can
#          also use true, to turn ON, or false, to turn OFF.
#
#    To later check what the value of a self switch is, use the code:
#      self_switch ("key")
#        key : the identifier for that self-switch. See line 17.
#      That will evaluate as the expression Self Switch Key == ON. If you want
#     to check if it is OFF, simply use the code:
#      !self_switch ("key")
#==============================================================================

#==============================================================================
# ** Game Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - control_self_switch
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Control Self Switch
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def control_self_switch (key, value)
    if value.is_a? (Symbol)
      value = value != :off ? 0 : 1
    elsif value
      value = 0
    end
    @params = [key, value]
    return command_123
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check Self-Switch
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def self_switch (key)
    return @original_event_id > 0 ? $game_self_switches[[@map_id, @original_event_id, key]] : false
  end
end

Credit



Thanks


Support


Please post here at RMRK.net for support.

Known Compatibility Issues

I didn't take very much care in choosing unique names because I wanted it to be simple to use. Thus, there could potentially be an issue there, but I don't know of any scripts that use the same method names and I don't think it will likely become an issue.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Extra Self Switches
Post by: ?????? on April 07, 2010, 06:29:26 PM
:dreamcast: Pretty cool... :dreamcast:
Title: Re: Extra Self Switches
Post by: hikick10 on May 08, 2010, 09:49:23 PM
May be the most useful script I've seen yet!
Ty modern.


:hammer:



:luigi: :m: