Skip to content

Instantly share code, notes, and snippets.

@nijikokun
Created May 27, 2022 13:57
Show Gist options
  • Save nijikokun/d01637caecce6ccb16afcce071f22732 to your computer and use it in GitHub Desktop.
Save nijikokun/d01637caecce6ccb16afcce071f22732 to your computer and use it in GitHub Desktop.
How to extend the RPG Maker MZ DataManager to store custom stuff for your plugin.
//===========================================================================
// Extend DataManager to persist specific changes
//===========================================================================
const RMMZ_DataManager_makeSaveContents = DataManager.makeSaveContents;
const RMMZ_DataManager_extractSaveContents = DataManager.extractSaveContents;
const RMMZ_DataManager_onLoad = DataManager.onLoad;
DataManager.makeSaveContents = function() {
const contents = RMMZ_DataManager_makeSaveContents.call(this);
contents._plugin_store = {};
}
DataManager.extractSaveContents = function(contents) {
RMMZ_DataManager_extractSaveContents.call(this, contents);
pluginRoot.data = contents._plugin_store;
}
DataManager.onLoad = function () {
RMMZ_DataManager_onLoad.apply(this, arguments);
console.log(arguments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment