Self Parameters VX
#1
Self Parameters VX
Version: 1

Introduction
First off, I'm not sure whether this is a good name for the script or not. If it isn't, suggest a new name. This script is pretty confusing to explain. Basically, it allows the developer to tag events with any kind of information. (example: Map 1's event 1's "gender" => "male") I'm not sure what it would be useful for, or how someone would make use of it but this was an idea I didn't want to go to waste. It's like self switches/my self variables script but for giving events certain information.

I'm having an awful time explaining this.

Features
  • Tag events with information.

Screenshots
No screenshots.

Demo
No demo.
Script
Code:
=begin
?????????????????????????????????????????????????????????????????????????????????
? Self Parameters VX                                                           ?
? Version 1.0                                                                  ?
? by PK8                                                                       ?
? November 4th, 2009                                                           ?
? http://rmvxp.com                                                             ?
?????????????????????????????????????????????????????????????????????????????????
? ? Table of Contents                                                          ?
? ?? Author's Notes                - Line 18?20                                ?
? ?? Introduction & Description    - Line 22?28                                ?
? ?? Features                      - Line 30?32                                ?
? ?? How to Use                    - Line 34?53                                ?
? ?? This aliases the following... - Line 55?58                                ?
? ?? Thanks                        - Line 60,61                                ?
? ?? Changelog                     - Line 63,64                                ?
????????????????????????????????????????????????????????????????????????????????
? ? Author's Notes                                                             ?
? A random idea came into my head. I'm not exactly sure how people would use it?
? but I didn't want to let this idea go to waste so I decided to make it.      ?
????????????????????????????????????????????????????????????????????????????????
? ? Introduction & Description                                                 ?
? This script is pretty 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.                               ?
?                                                                              ?
? Self Parameters allows users to set certain parameters pertaining to a       ?
? specific event. Examples include: An event's gender.                         ?
????????????????????????????????????????????????????????????????????????????????
? ? Features                                                                   ?
? ? Set self parameters of an event via call script. (How to use is below)     ?
? ? Get self parameter of an event via call script. (How to use is below)      ?
????????????????????????????????????????????????????????????????????????????????
? ? How to Use                                                                 ?
?                                                                              ?
? ? Setting up a self parameter:                                               ?
?   To set a self parameter for an event, you'll need to call this script on a ?
?   map event:                                                                 ?
?     self_parameter(id, value)                                                ?
?       id:     Self Parameter Identification. Example: 'gender'               ?
?       value:  Give it a value.                                               ?
?                                                                              ?
? ? Getting a self parameter:                                                  ?
?   To get a self parameter for an event, you can call this script.            ?
?     self_parameter(id)                                                       ?
?       id:     Self Parameter Key.                                            ?
?                                                                              ?
? ? Using self variables in evented if conditions.                             ?
?   You're probably wondering how, right? Alright. 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:                                ?
?     self_parameter(id) == value     <- Equal to.                             ?
?     self_parameter(id) != value     <- Not Equal to.                         ?
????????????????????????????????????????????????????????????????????????????????
? ? This aliases the following...                                              ?
? create_game_objects        - Scene_Title < Scene_Base                        ?
? write_save_data            - Scene_File < Scene_Base                         ?
? read_save_data             - Scene_File < Scene_Base                         ?
????????????????????????????????????????????????????????????????????????????????
? ? Thanks                                                                     ?
? Lowell: He liked the idea which was enough for me to want to make it.        ?
????????????????????????????????????????????????????????????????????????????????
? ? Changelog                                                                  ?
? Version 1.0 - 11/04/09: Initial Release                                      ?
?????????????????????????????????????????????????????????????????????????????????
=end

#==============================================================================
# ** Game_SelfParameters
#------------------------------------------------------------------------------
#  This class handles self parameters. It's a wrapper for the built-in class
# "Hash." The instance of this class is referenced by $game_self_parameters.
#==============================================================================

class Game_SelfParameters
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @data = {}
  end
  #--------------------------------------------------------------------------
  # * Get Self Parameter
  #     key : key
  #--------------------------------------------------------------------------
  def [](key)
    if @data[key] != nil
      return @data[key]
    end
  end
  #--------------------------------------------------------------------------
  # * Set Self Parameter
  #     key   : key
  #     value : key's value
  #--------------------------------------------------------------------------
  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
  def self_parameter(id, value = nil)
    if @event_id > 0
      key = [@map_id, @event_id, id]
      if value != nil
        $game_self_parameters[key] = value
      else
        return $game_self_parameters[key]
      end
      if value != nil
        $game_map.need_refresh = true
        return true
      end
    end
  end
end

#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs the title screen processing.
#==============================================================================

class Scene_Title < Scene_Base
  alias pk8_self_parameters_create_game_objects :create_game_objects
  #--------------------------------------------------------------------------
  # * Create Game Objects
  #--------------------------------------------------------------------------
  def create_game_objects
    pk8_self_parameters_create_game_objects
    $game_self_parameters = Game_SelfParameters.new
  end
end

#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
#  This class performs the save and load screen processing.
#==============================================================================

class Scene_File < Scene_Base
  alias pk8_self_parameters_write_save_data  :write_save_data
  alias pk8_self_parameters_read_save_data   :read_save_data
  #--------------------------------------------------------------------------
  # * Write Save Data
  #     file : write file object (opened)
  #--------------------------------------------------------------------------
  def write_save_data(file)
    pk8_self_parameters_write_save_data(file)
    Marshal.dump($game_self_parameters, file)
  end
  #--------------------------------------------------------------------------
  # * Read Save Data
  #     file : file object for reading (opened)
  #--------------------------------------------------------------------------
  def read_save_data(file)
    pk8_self_parameters_read_save_data(file)
    $game_self_parameters = Marshal.load(file)
  end
end

Instructions
Instructions are in the script.

FAQ
Definitely awaiting question.

Compatibility
Aliases:
Scene_Title < Scene_Base's create_game_objects, Scene_File < Scene_Base's write_save_data and read_save_data.

Credits and Thanks
Credit me.

Author's Notes
The script was a pretty random idea. Anyway, I'm not too sure how anyone would use this script. It's so quirky! But Lowell liked the idea behind it so I'm sure he'll figure something out.

Terms and Conditions
Exclusive to RMVXP.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
   Self Parameters v1.1 PK8 0 407 11-25-2009, 12:21 AM
Last Post: PK8



Users browsing this thread: 1 Guest(s)