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.
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
本贴来自国际rpgmaker官方论坛作者:VolcoV处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/modsavedataplugin.123348/