11-25-2009, 12:21 AM
(This post was last modified: 09-02-2024, 09:47 PM by DerVVulfman.)
Self Parameters
Version: 1.1
Version: 1.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.
Edit:
DerVVulfman Wrote:Remember how to set and retrieve .ini values for windows? Same difference, but using events to narrow the data further.Also, check out the Auto Self Parameters add-on script.
Within an event, you can call self_parameter(id, value) to set a single identifiable id string (ie 'gender'), and then set that id's value (like 'male'). That id/value combination is unique for that event. Go to another event, and you can set THAT value to female. Each event can be set to a different value for that id.
You can then use value = self_parameter(id) to retrieve that same said value.
Now if you want to have a default set of values, look into his 'Autoselfparameters' add-on... I think.
Features
- Tag events with information.
Screenshots
No screenshots.
Demo
No demo.
Script
Code:
=begin
?????????????????????????????????????????????????????????????????????????????????
? Self Parameters ?
? Version 1.1 ?
? by PK8 ?
? November 2nd, 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?63 ?
? ?? Thanks - Line 65,66 ?
? ?? Changelog - Line 68?70 ?
????????????????????????????????????????????????????????????????????????????????
? ? 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... ?
? RMXP Version: ?
? command_new_game - Scene_Title ?
? write_save_data - Scene_Save < Scene_File ?
? read_save_data - Scene_Load < Scene_File ?
? RMVX Version: ?
? 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 (MM/DD/YYYY) ?
? v1.0 (11/02/2009): Initial Release ?
? v1.1 (11/24/2009): "Merged" the RMXP and RMVX versions. ?
?????????????????????????????????????????????????????????????????????????????????
=end
#==============================================================================
# IMPORTANT! RMVX users, set this to false!
#==============================================================================
class PK8
Self_Parameters_RMXP = true
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
#===============================================================================
# * RMXP Version
#===============================================================================
if Self_Parameters_RMXP == true
#=============================================================================
# ** Interpreter
#-----------------------------------------------------------------------------
# This interpreter runs event commands. This class is used within the
# Game_System class and the Game_Event class.
#=============================================================================
class 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
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias pk8_self_parameters_command_new_game :command_new_game
#--------------------------------------------------------------------------
# * Create Game Objects
#--------------------------------------------------------------------------
def command_new_game
pk8_self_parameters_command_new_game
$game_self_parameters = Game_SelfParameters.new
end
end
#=============================================================================
# ** Scene_Save
#-----------------------------------------------------------------------------
# This class performs save screen processing.
#=============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias pk8_self_parameters_write_save_data :write_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
end
#=============================================================================
# ** Scene_Load
#-----------------------------------------------------------------------------
# This class performs load screen processing.
#=============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias pk8_self_parameters_read_save_data :read_save_data
#--------------------------------------------------------------------------
# * 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
end
#===============================================================================
# * RMVX Version
#===============================================================================
if Self_Parameters_RMXP == false
#=============================================================================
# ** 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 Listings
#--------------------------------------------------------------------------
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 Listings
#--------------------------------------------------------------------------
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
end
Instructions
Instructions are in the script.
FAQ
Definitely awaiting question.
Compatibility
Aliases:
Scene_Title's command_new_game, Scene_Save < Scene_File's write_save_data and Scene_Load < Scene_File's read_save_data. - RMXP
Scene_Title < Scene_Base's create_game_objects, Scene_File < Scene_Base's write_save_data and read_save_data. - RMVX
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.