RPG Maker XP
Persistent Data Script
Introduction
Persistent data is a data that is still exist when the player visit the game again. The example of this is stuff like a “New Game +” feature on some game, system setting, unlockables and gallery. However, RMXP only load stored data when a player load a specific save file, which is rather inconvenient when we’re trying to make a system similar to those I’ve mentioned before.
This script enables the game to load certain ingame switches and variables automatically when the game starts.
Features
– Enable normal switches and variables as a Persistent Data
The Code
License Terms
Attribution-ShareAlike 3.0 Unported - You must attribute the work in the manner specified by the author or licensor. The licensor permits others to distribute derivative works only under the same license or one compatible with the one that governs the licensor's work. Commerical use allowed.
Frequently Asked Questions
If there’s any updates for the script, it’ll be available first on this page :
The Script Page on My WordPress
I’ll update it here too, but just in case that I forget, check the link above first.
Instructions
Here’s how to set this script up. First, put the script on your game. Chose switches and variables that you want to treat as persistent data. Put [p] somewhere in their name (note that the p is in lower case).
When you made some changes on the persistent data, save it using these script call :
$scene = Save_System.new
The variables will be stored on a file named System.rxdata. And you’re done! This script will load the data stored in that file when player run the game, and load it again when player start a new game, and after the player load a game from a certain save file.
Compatibility
– No Compatibility issue yet.
Version History
Version 1.0 (19 November 2015) – Initial design.
Credits & Thanks
Black Mage
Terms & Conditions
Terms of Use :
1. This script can be used on commercial or non commercial games, only if you credit me (Black Mage) properly.
2. Please tell me about your game (Optional). I’ll be happy to play and review your game, assumed I have some times to spare.
Anyway, it’s licensed under Attribution-ShareAlike 3.0 Unported
Comments (11)
Leave a Reply
You must be logged in to post a comment.
Kitsuki
This is such a coincidence! Two minutes ago, I was searching for the exact same thing–like a global save that carries from save file to save file. I found a similar way to do it through events, but I think this will be much more useful!
Hm, is there a script command that will reset the switches so that the save files are erased? For example, if a player wants to reset a game to how it was in the beginning, without "New Game +" and he chooses an option I provide in a menu or something, is there a script command that I can then run to erase these switches/variables?
Great work, Mage! This will be super useful in my game. 😀
black mage
Yes, put this on script call right when the game started on the map.
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
Kitsuki
Thanks! I just tested the script out in my game, and it works like a charm.
Great work once again, Mage!
Lawrence
– It doesn't work for me.
An error like "invalid use of 'include?' " pops up every time
After that it keeps saying "end of line error" until I copy my game back from a backup
What am I doing wrong?
black mage
Can you elaborate more on what are you doing? It's hard to pinpoint the problem only with the data you provided. A method on how to create the errors would be nice. A demo would be great in case there's some incompatibility with another script.
Lawrence
Well all I did was this:
I've put the Script after "Scene_Save" and "Scene_Load"
then I've put the [p] at the beginning of the variable name that I need to save
the first error ("invalid use of " include" " ) pops up when I'm trying to save it with "$scene = Save_System.new" command (I was using an event on map)
after that It keeps saying the second error when I start the game
I'm sure that I forgot something obvious but I can't figure what
black mage
Strange. I tried your method on a fresh project and it works well. Maybe it's incompatibility with certain scripts. Can you upload a small demo of your project where the errors could occur? Mediafire or dropbox would be fine.
Lawrence
Ok, just a second
Lawrence
I've sent it to you in PM, thanks for your help
( Don't worry I will write the solution if this is gonna be fixed, to help other people with my same problem )
black mage
A fix for nil named switches and variables caused by initialization from script has been added to the script. Hope this solve the problem 🙂
Lawrence
It works!
So it did that error because I had some unnamed variables and switches.
Thank you very much! 🙂 🙂