[RGSS3] Object Reinitializer

This script attempts to fix many issues that were caused by loading an old save when new scripts were installed. This script is NOT foolproof, but it will prevent a large number of errors from occurring.

Warning: Several issues with this script have been identified. There is currently no fix for it, and no ETA on when a new one will be available, but some bits of data, such as player equips will be lost.

Get the reinitializer on my archive. Current Version: 1.0.2

Installing the script

To install this script, place it in the materials section.

Configuration

This script does not have any configuration options.

trans.gif


Additional Information

None

Version History

V 1.0.2

Spoiler
Made followers reinitialize completely, fixing any bugs when adding variables into Game_CharacterBase or Game_Character

Did the same for Game_Actors to fix any errors from changes in Game_BattlerBase or Game_Battler
V 1.0.1

Spoiler
Fixed a bug where followers would stop following the player after loading a save.
V 1.0.0

Spoiler
Initial release.
About time you slow useless good for noth-

nice job~!
Looks good. Simply create a new object and transfer existing data over from the save data to make sure everything exists.
nice one. this will help for one who already have save in the middle of the game and too lazy to change the starting point (and alter switch and variable).
Nice script and simple solution...

What was the original problem? New methods and instance variables of classes modified by scripts that the unmarshalled object doesn't have?

And what about objects that have other objects as instance variables? Like $game_actors, $game_troop etc.? Won't there be problems when having a script that modifies the Game_Actor or Game_Enemy classes etc.?
What was the original problem? New methods and instance variables of classes modified by scripts that the unmarshalled object doesn't have?
That's essentially it. New scripts added expect certain data to be there, but the save file doesn't have it, the new script goes to use it, and it can't work properly and, usually, ends up crashing the game.

How it works

Before the save file is actually loaded, goes through its contents, and for each set of data, it will create a new object (unless that set of data is something that can't make a new object, like true or false) of the same type (Game_Player, Game_Map, etc), and this new object will have all the information that the new scripts would have put in there by default. Then, before we're done, we take the information that was in the save file, and put those into the new objects, which are then put back into the save file's data.

The actual file is not modified unless they save over it again.

Edit:

and no, those variables are fine. Those are what are being modified, actually. The script will go through each data set in the save file (by default all the Game_whatever scripts except for a few of them), and then make a new one of those (with the new scripts affecting them). Then, all the values from the old one will be copied over to the new one, making it so that anything a new script adds will be there, while data from the save will be kept as well.

I suppose that if a scripter changes the type of data stored in a variable that already exists (not exactly a good idea, unless it's for a very specific reason), then this shouldn't have any issues.
Wow I am impressed here this will help me out a million tiles a year.

- I needed this just about 5 mins ago.

just had added oc-animated gauges

tried the continue I had used and it nil errored

then started new game it worked fine.

SO what's this script suposed to do?
Wow I am impressed here this will help me out a million tiles a year.

- I needed this just about 5 mins ago.

just had added oc-animated gauges

tried the continue I had used and it nil errored

then started new game it worked fine.

SO what's this script suposed to do?
What script are you using?
I am using a lot of scripts (50+)in my project and they all run fine with no errors.

(I have had extensive testing done)

but I had wanted to use a previous continue as your script said it allowed.
I am using a lot of scripts (50+)in my project and they all run fine with no errors.

(I have had extensive testing done)

but I had wanted to use a previous continue as your script said it allowed.
Sorry for the very late reply, I've been very busy, what is the exact error it's giving you?
The script has been updated to V 1.0.1 to fix a bug where followers would stop following the player after you load a save.
btw, how about the values for those things? especially those that load data from notetags...
If the data is stored in an instance variables (anything starting with a single '@'), then it will be copied over to the new object.

Edit: All other data is left as it is when a new instance of a class is created. The game's followers, though, are re-modified so that they continue to follow the leader (the first follower's @preceding_character must be set to the proper instance of the Game_Player class, or else they'd stop moving after the first step in a loaded file.
Version 1.0.2 has been uploaded that should fix any issues with followers or actors having issues with new scripts expecting variables (even if you don't use followers, RM will till update them and cause potential errors). This script is NOT foolproof, and some scripts may still error, due to when it tries to access a certain variable (if a new variable is expected when running initialize but was not created before the method was called most likely will crash, regardless of this script), so please do not expect this script to fix any save file issue.
10/10 would break again so he can fix it. Works like a charm after each fix~
Is there a particular reason why you chose to copy values from the saved objects into the newly initialized objects, rather than copying values from the newly initialized objects into the saved objects?
Is there a particular reason why you chose to copy values from the saved objects into the newly initialized objects, rather than copying values from the newly initialized objects into the saved objects?
When I first made it, my thinking was that copying the old into the new would ensure all the old data exists while any new data was created. Now, though, I suppose I should be able to easily copy the new into the old by comparing the two values and seeing which ones exist in the new but not the old, and only take those. I'll test some new methods and see what seems to be the best.

Edit:

Thinking a bit more about that now, I don't think just copying values from the old into the new will work so much because things like the followers will not work again.
You mentioned the follower issue in another topic but I'm still confused about why it's a problem.

We're sure the default loading process works: followers are following the player correctly as they were when the game was saved.

When you add some logic to copy new data over to "patch up" the old save file, the followers would (or should) still be referencing the same player object (which is the one retrieved from the save file).

Basically, the player that's passed into the followers array should be equal to $game_player

class Game_Player def initialize super @vehicle_type = :walk # Type of vehicle currently being ridden @vehicle_getting_on = false # Boarding vehicle flag @vehicle_getting_off = false # Getting off vehicle flag @followers = Game_Followers.new(self) @transparent = $data_system.opt_transparent clear_transfer_info endclass Game_Followers def initialize(leader) @visible = $data_system.opt_followers @gathering = false # Gathering processing underway flag @data = [] @data.push(Game_Follower.new(1, leader))It's just the $game_player reference being tossed around.If the serialization process actually breaks this reference (perfectly possible) such that the first follower isn't following $game_player anymore...then I'm wondering how the default scripts work. There doesn't appear to be any special handling after the save file is loaded where the follower's leader is updated or anything.

EDIT: my post shouldn't belong in a script release thread so I've made another topic about it here: http://forums.rpgmakerweb.com/index.php?/topic/35329-patch-old-save-files-with-new-data

Original thread: https://forums.rpgmakerweb.com/threads/rgss3-object-reinitializer.18457/