Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // μ'ki's Self Variables v1.00
- // MK_SelfVariables.js
- //=============================================================================
- var Imported = Imported || {};
- var Maki = Maki || {};
- Maki.SV = Maki.SV || {};
- //=============================================================================
- /*:
- * @plugindesc v1.00 Self Variables
- * @author μ'ki
- *
- * @help
- * ============================================================================
- * Introduction
- * ============================================================================
- * The RPG MV default game system has self switches data, but you may also need
- * 'self variables' that belong to each event object like self switches do.
- * That was inspired by RPG VX script "Rei Self Variable", which can be found
- * at RPGMakerID forum, so that I developed this RPG MV plugin for it.
- *
- * Contact me for support/bug report:
- * listra92[at]gmail.com
- *
- * ============================================================================
- * Features and Usages
- * ============================================================================
- * - Allows self variables data to be stored in the game save data.
- * - Provides easier access to self variables and switches:
- * $gameSelfVariables.valueOf(eventId, 'name')
- * $gameSelfVariables.setValueOf = function(eventId, 'name', value);
- * $gameSelfSwitches.valueOf(eventId, 'name')
- * $gameSelfSwitches.setValueOf = function(eventId, 'name', value);
- *
- * Note: The self switch names by default are 'A', 'B', 'C' and 'D', but
- * here you can define the names by yourself.
- *
- */
- //=============================================================================
- //=============================================================================
- // Parameter Variables
- //=============================================================================
- Maki.SV.Parameters = PluginManager.parameters('MK_SelfVariables');
- //-----------------------------------------------------------------------------
- // Game_SelfVariables
- //-----------------------------------------------------------------------------
- function Game_SelfVariables() {
- this.initialize.apply(this, arguments);
- }
- Game_SelfVariables.prototype.initialize = function() {
- this.clear();
- };
- Game_SelfVariables.prototype.clear = function() {
- this._data = {};
- };
- Game_SelfVariables.prototype.value = function(key) {
- return this._data[key] || 0;
- };
- Game_SelfVariables.prototype.setValue = function(key, value) {
- this._data[key] = value;
- this.onChange();
- };
- Game_SelfVariables.prototype.valueOf = function(eventId, name) {
- var key = [$gameMap._mapId, eventId, name];
- return this.value(key);
- };
- Game_SelfVariables.prototype.setValueOf = function(eventId, name, value) {
- var key = [$gameMap._mapId, eventId, name];
- this.setValue(key, value);
- };
- Game_SelfVariables.prototype.onChange = function() {
- $gameMap.requestRefresh();
- };
- //-----------------------------------------------------------------------------
- // Game_SelfSwitches
- //-----------------------------------------------------------------------------
- Game_SelfSwitches.prototype.valueOf = function(eventId, name) {
- var key = [$gameMap._mapId, eventId, name];
- return this.value(key);
- };
- Game_SelfSwitches.prototype.setValueOf = function(eventId, name, value) {
- var key = [$gameMap._mapId, eventId, name];
- this.setValue(key, value);
- };
- //-----------------------------------------------------------------------------
- // DataManager
- //-----------------------------------------------------------------------------
- var $gameSelfVariables = null;
- Maki.SV.DataManagerCreateGameObjects = DataManager.createGameObjects;
- DataManager.createGameObjects = function() {
- Maki.SV.DataManagerCreateGameObjects.call(this);
- $gameSelfVariables = new Game_SelfVariables();
- };
- Maki.SV.DataManagerMakeSaveContents = DataManager.makeSaveContents;
- DataManager.makeSaveContents = function() {
- // A save data does not contain $gameTemp, $gameMessage, and $gameTroop.
- var contents = Maki.SV.DataManagerMakeSaveContents.call(this);
- contents.selfVariables= $gameSelfVariables;
- return contents;
- };
- Maki.SV.DataManagerExtractSaveContents = DataManager.extractSaveContents;
- DataManager.extractSaveContents = function(contents) {
- Maki.SV.DataManagerExtractSaveContents.call(this, contents);
- $gameSelfVariables = contents.selfVariables;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement