[CGMZ] Patch (Patreon)
Downloads
Content
Instead of abandoning saves from before an update, patch their data so your players can still use their old saves with your new update.
! SEE BOTTOM OF POST FOR UPDATES !
Hi all, introducing [CGMZ] Patch!
This plugin allows you to patch save data when a saved game is loaded. This can help if your update changes database, switch or variable objects around, plugin data changes, or anything really. It aims to provide easy automatic parameters for certain things while also providing a custom JS parameter for third party plugin data.
The Problem
When you are actively developing your game and you already have players, such as a demo version that is being updated as your development proceeds, sometimes you may make changes that cause old save files to no longer work. When loading such a save file the game may behave weirdly due to having switches and variables in states that would now be impossible, or it may even crash when loading the old save if data was removed but still exists in your save game.
[CGMZ] Patch Solution
What if, instead of just telling your players to restart and abandon their save files from before the update, you as the developer could patch any save data on load so that they can keep their save files? With this plugin, you can do exactly that! Of course, it is a bit of an advanced plugin because you will need to understand what changes need to be made to save files to make them up to date with the current version of your game.
Example
As one example of how you may use this plugin, lets say you have a plugin that adds custom vehicle data to the vehicles array which is checked when the game is loaded to refresh the vehicles. If you decide to uninstall this plugin from your game, that custom vehicle data will still be there in your saved game's data although it will not be able to be read anymore because the custom vehicle plugin no longer exists in your game.
This could cause a crash when trying to load a save game from before the plugin was removed, for example:
Normally in this scenario you would need to tell your players to just start a new game. However, with [CGMZ] Patch you can create a patch that removes this now unused data from their save files, allowing the save file to load successfully:
Of course, the possibilities are almost endless. You should be able to patch just about anything, whether it be removing old unused data from saved games, adding new data that may be missing from saved games, or modifying existing data to add new parameters.
No Code Patching
This plugin aims to make creating patches for saved data as easy as possible. For this, there are some built-in patch commands to clear out any previously used variables or switches. You can also turn a switch ON in a patch. For example, if you previously used to set a variable to some number but now that variable is no longer used (or used for something different), you can reset it to 0 in your saved games with this plugin.
JavaScript Patching
Beyond the easy no-code patching for switches and variables, you can also run custom JavaScript code in your patches. This allows you to fix any save data, provided you know the JavaScript to do so and the state your save data is in on your saved game. You could even fix third party plugin save data with this.
Roadmap
The functionality that already exists should work flawlessly in your game. However, some features are not yet in this version of the plugin. Below are planned features to be added through updates during the Alpha and Beta process, in no particular order:
Option to manage player items, weapons, armors through plugin params
Conditions on switches or variables
Option to change player location
Do you have any ideas you'd like to see added to the plugin not already listed above? Let me know in the comments or in my Discord's #suggestion channel! I appreciate all suggestions I get and add them all to my to-do list.
Happy RPG Making!
This version adds some debug plugin commands, allowing you to reset save files so patches run again. This is useful if you want to debug your patch before releasing it for your players, as you will be able to run the patch, then change certain things and reset the patch version to cause it to run again under different conditions.
A plugin command to get the current patch version was also added, in case you want to display the current patch version anywhere.
This version adds the option to conditionally change the player location. It works by map id. This means if you change map id 10, and you need to reset the player's location if they happen to have saved on that map or something, you can now do so. Players not on the given map ids will not be moved.
This update also adds a Note parameter as the first parameter for each Patch. This is not used by the plugin, but for your use in helping remember what your patches do. It is first so you can easily see it from the main patch list without needing to click into each patch.