Saving Additional Data to Save Files

So I'm having a problem which I believe comes from what the RPG Maker VX Ace engine saves in a save file.  I'm creating an appendix of all items in the game, however you can only view the information on items your party has, or had in the past (like in Etrian Odyssey 4, if you've played that).  I have a variable $seen_items in Game_Party.  It is an array of the same length as $data_items, created with a default value of false.  I've changed the "Change Items" event command so it also sets the element of $seen_items at the index of the item gained in $data_items to true.  Then, in the appendix, the item information is only displayed for items that have their corresponding element in $seen_items set to true.  This all works fine until you save and reload the game.  $seen_items is reset to all false when you open the game from a save file.  Is there a way to include $seen_items in the save file, so that you can reload the game, and it will reload the $seen_items variable?  Or is there another way of doing this that does not require saving additional data?
Well, you could simply assign a range of Switches (such as Switch #3501 through Switch #4000) to the range of items in your game, and set Switch #(3500 + Item ID) to TRUE when the player gains an item.  Likewise, you'd check in the Appendix for "is Switch #(3500 + Item ID) true?"


It probably wouldn't hurt to learn how to save extra data, though.  If you go to the DataManager script, you can see most of the methods used to save and load data.  Since you are trying to access information that's unique to the file level (not the database level because it can be different in each save file), you will probably want to alias/modify the make_save_contents and extract_save_contents methods.  Just add your new $global_objects there in the same pattern as the objects that are already there and I think that might even be all you need to do.  You can also follow these methods up in the chain by using Find, to see when they get called (such as the Marshal "dump"s which are run as part of the Save process).
Or you can simply put it into Game_System and be done with it without touching any other methods.


You can than access it with $game_system.seen_items anytime, anywhere.


Game_System is saved by default, so adding such trivial things into it is fine, if not flat out better than messing with 2 other methods needlessly.


Now, if you were to save something more complicated (like entire new systems and their elements), it might be better to save it into a new file, but that is not the case here.


You also have some other classes which get saved by default, like Game_Party (for global things) and any Game_Actor instances (for actor specific things).

Original thread: https://forums.rpgmakerweb.com/threads/saving-additional-data-to-save-files.63366/