Common Event Self Switches VX
#1
Common Event Self Switches VX
Version: 1

Introduction
This script is a similar to that of the built in feature: Self Switches. For those not familiar with Self Switches, Self Switches pretty much pertain to a specific event. Example: Treasure Chests.

Common Event Self Switches allows developers to set certain switches pertaining to a certain Common Event.

Features
  • Set Common Event's self switches via call script.
  • Get Common Event's self switches via call script.

Screenshots
No screencaps.

Demo
No demo.

Script
Code:
=begin
????????????????????????????????????????????????????????????????????????????????
? Common Event Self Switches VX                                                ?
? Version 1.0                                                                  ?
? by PK8                                                                       ?
? 9/16/09                                                                      ?
? http://rmvxp.com                                                             ?
????????????????????????????????????????????????????????????????????????????????
? ? Table of Contents                                                          ?
? ?? Author's Notes                - Line 18?21                                ?
? ?? Introduction & Description    - Line 23?29                                ?
? ?? Features                      - Line 31?33                                ?
? ?? How to Use                    - Line 35?57                                ?
? ?? This aliases the following... - Line 59,60                                ?
? ?? Thanks                        - Line 62?66                                ?
? ?? Changelog                     - Line 68,69                                ?
????????????????????????????????????????????????????????????????????????????????
? ? Author's Notes                                                             ?
? Lowell/Adalwulf mentioned creating a "Personal Variables" system which filled?
? my head in with ideas about variables and switches. One of these ideas being ?
? giving COMMON EVENTS their own self switches.                                ?
????????????????????????????????????????????????????????????????????????????????
? ? Introduction & Description                                                 ?
? This script is a similar to that of the built in feature: Self Switches.     ?
? For those not familiar with Self Switches, Self Switches pretty much pertain ?
? to a specific event. Example: Treasure Chests.                               ?
?                                                                              ?
? Common Event Self Switches allows developers to set certain switches         ?
? pertaining to a certain Common Event.                                        ?
????????????????????????????????????????????????????????????????????????????????
? ? Features                                                                   ?
? ? Set Common Event's self switches via call script. (How to use is below)    ?
? ? Get Common Event's self switches via call script. (How to use is below)    ?
????????????????????????????????????????????????????????????????????????????????
? ? How to Use                                                                 ?
?                                                                              ?
? ? Setting up a Common Event's self switch:                                   ?
?   To set a self switch for a common event, you'll need to call this script:  ?
?     ce_self_switch(ceid, id, bool)                                           ?
?       ceid: Common Event's ID                                                ?
?       id:   Common Event's Self Switch ID. Example: 'A', 'B'                 ?
?       bool: true or false.                                                   ?
?   Example: ce_self_switch(1, 'A', true) sets the first Common Event's switch ?
?            "A" to true.                                                      ?
?                                                                              ?
? ? Getting a Common Event's self switch:                                      ?
?   To get a self switch of a Common Event, you can call this script.          ?
?     ce_self_switch(ceid, id)                                                 ?
?       ceid: Common Event's ID                                                ?
?       id:   Common Event's Self Switch ID. Example: 'A', 'B'                 ?
?   Example: ce_self_switch(1, 'A') gets Common Event's switch "A".            ?
?                                                                              ?
? ? Using Common Event's self switches in evented if conditions.               ?
?   To do this, go to the conditional branch event command, click on the fourth?
?   tab, select Script and type either of these in the input form:             ?
?       ce_self_switch(ceid, id) == true                                       ?
?       ce_self_switch(ceid, id) == false                                      ?
????????????????????????????????????????????????????????????????????????????????
? ? This aliases the following...                                              ?
? initialize - Game_Map                                                        ?
????????????????????????????????????????????????????????????????????????????????
? ? Thanks                                                                     ?
? Lowell: He mentioned creating a personal variables system for his project    ?
?         which made me catch "the scripting bug".                             ?
? Kain Nobel: I'm using Kain Nobel's modifications to the Actor & Party's Self ?
?             switches script as a base.                                       ?
????????????????????????????????????????????????????????????????????????????????
? ? Changelog                                                                  ?
? Version 1.0 - 9/16/09: Initial Release                                       ?
????????????????????????????????????????????????????????????????????????????????
=end

#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  attr_accessor :ce_self_switches
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :ceselfswitches_gmmap_initialize, :initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args)
    ceselfswitches_gmmap_initialize(*args)
    @ce_self_switches = Game_Map::CE_SelfSwitches.new
  end
end

#==============================================================================
# ** Game_Map::CE_SelfSwitches
#------------------------------------------------------------------------------
#  This handles switches. It's a wrapper for the built-in class "Array."
# The instance of this class is referenced by $game_map.ce_self_switches.
#==============================================================================

class Game_Map::CE_SelfSwitches
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @data = {}
  end
  #--------------------------------------------------------------------------
  # * Get Self Switch of Common Event
  #     key : key
  #--------------------------------------------------------------------------
  def [](key)
    return @data[key] == true ? true : false
  end
  #--------------------------------------------------------------------------
  # * Set Self Switch of Common Event
  #     key   : key
  #     value : ON (true) / OFF (false)
  #--------------------------------------------------------------------------
  def []=(key, value)
    @data[key] = value
  end
end

#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Control Common Event Self Switch
  #--------------------------------------------------------------------------
  def ce_self_switch(ceid, id, bool = nil)
    if $data_common_events[ceid].id > 0 and $data_common_events[ceid] != nil
      key = [$data_common_events[ceid].id, id]
      if bool != nil
        $game_map.ce_self_switches[key] = bool
      else
        return $game_map.ce_self_switches[key]
      end
    end
    $game_map.need_refresh = true
    return true
  end
end

Instructions
Instructions on how to use it are in the script.

FAQ
Awaiting question.

Compatibility
Aliases initialize of Game_Map.

Credits and Thanks
Lowell: He mentioned creating a personal variables system for his project which made me catch "the scripting bug".
Kain Nobel: I'm using Kain Nobel's modifications to the Actor & Party's Self switches script as a base.

Author's Notes
Lowell/Adalwulf mentioned creating a "Personal Variables" system which filled my head in with ideas about variables and switches. One of these ideas being giving COMMON EVENTS their own self switches.

Terms and Conditions
Possibly exclusive to RMVXP.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Event Location Saver 1.1 ixfuru 0 4,632 12-07-2016, 11:36 PM
Last Post: ixfuru
   Troop : Self-Switches Kain Nobel 0 120 06-10-2016, 05:58 PM
Last Post: Kain Nobel
   Event Comment Conditionals ixfuru 3 6,932 08-05-2015, 02:31 AM
Last Post: JayRay
   ELSA (Event Layering Script Advance) JayRay 0 134 02-25-2015, 08:34 PM
Last Post: JayRay
   Event Transparency DerVVulfman 0 125 03-09-2013, 06:00 AM
Last Post: DerVVulfman
   The Event Extenders Grimimi 2 6,877 09-01-2012, 05:54 AM
Last Post: Grimimi
   Group Switches v1.1 PK8 0 159 11-12-2009, 06:24 AM
Last Post: PK8
   Common Event Self Variables VX PK8 0 923 09-17-2009, 04:55 AM
Last Post: PK8
   [Unsupported] Actor & Party's Self Switches VX PK8 0 5,117 09-16-2009, 10:57 PM
Last Post: PK8
   Call Event VX woratana 0 4,558 01-22-2009, 01:13 PM
Last Post: woratana



Users browsing this thread: 1 Guest(s)