I wish to share my save data plugin with no copyright/license restritions. I wish to purpose as a convenant of mods memory usage where the main core objects doesn't need to be modified adding attributes.
Data stored in $modData object is 100% serializable and will be stored when game is saved and any plugin that uses ModSaveDataPlugin won't have any problem with other mods compatibilities beacause their data will be isolated from other mods data.
Also data will have a better and visual structure.
Version: 1.0.0
Last update: 29/06/2020
Data stored in $modData object is 100% serializable and will be stored when game is saved and any plugin that uses ModSaveDataPlugin won't have any problem with other mods compatibilities beacause their data will be isolated from other mods data.
Also data will have a better and visual structure.
JavaScript:
//=============================================================================
// ModSaveDataPlugin.js
//=============================================================================
/*:
* @plugindesc Mod that provides a serializable object for mod data saving.
* @author VolcoV
*
* @help
*
* Mod data plugin provides a new serializable object: $modData wich can store
* any kind of JSON data from scripts. (As serializable object, it will be
* saved and loaded on save/load game).
*
* Use example:
*
* $modData.myProfessionsMod = {
* alchemy: {
* character: 1,
* level: 3,
* exp: 61,
* nextLevel: 127
* },
* smithing: {
* character: 1,
* level: 3,
* exp: 61,
* nextLevel: 127
* }
* };
*
* const alchemyLevel = $modData.myProfessionsMod.alchemy.level;
*
*
* Why should I use ModSaveData:
*
* - No license comercial/personal restrictions. That plugis is under MIT
* license: https://opensource.org/licenses/MIT
* - Less plugins incompatibilities: data structure is isolated from
* core structure
* - Data is saved when game is saved and restored when game is loaded.
*
* Usage:
*
* - Plugin must be included listed before the plugins that will use $modData.
* - $modData will be cleared on new game start. If your plugin needs to add
* initial data to $modData consider to add this data modifying
* DataManager.setupNewGame in your plugin. Example:
*
* let _DataManager_setupNewGame = DataManager.setupNewGame;
* DataManager.setupNewGame = function() {
* _DataManager_setupNewGame.call(this);
* $modData.myPluginData = {
* yourPlugin: 'initializationExample'
* };
* }
*
* @link JSON format documentation: https://www.json.org/json-en.html
*/
(() => {
window['$modData'] = {};
let _DataManager_makeSaveContents = DataManager.makeSaveContents;
DataManager.makeSaveContents = function () {
const contents = _DataManager_makeSaveContents.call(this);
contents.modData = $modData;
return contents;
};
let _DataManager_extractSaveContents = DataManager.extractSaveContents;
DataManager.extractSaveContents = function (contents) {
_DataManager_extractSaveContents.call(this, contents);
$modData = contents.modData || {};
};
let _DataManager_setupNewGame = DataManager.setupNewGame;
DataManager.setupNewGame = function() {
_DataManager_setupNewGame.call(this);
$modData = {};
};
})();
Version: 1.0.0
Last update: 29/06/2020