Adding persistent data, how to use DataManager

How much hassle would this be to do? Really, all I'm looking to do, or would be interested to learn how to do, is add information to the Event class (just some strings and integers) in such a way that it is preserved properly with Saves / Loads. I'm fine with adding to the class definition to add custom member data, accessors and functions, but it's how this info can be saved and loaded back that interests me.
Look for PK8's Self data suite, it's on the master script list.


Those scripts should do what you want - they add self switches, self variables and meta data to everything from actor to maps.
How much hassle would this be to do? Really, all I'm looking to do, or would be interested to learn how to do, is add information to the Event class (just some strings and integers) in such a way that it is preserved properly with Saves / Loads. I'm fine with adding to the class definition to add custom member data, accessors and functions, but it's how this info can be saved and loaded back that interests me.
You could also just make a parallel list of data objects that your events have new functions for accessing them. I warn you though, that the event data system is fairly complex, so this may be more complex than you would otherwise think.

I did use a system like this in my current game that ties a person object to an event that represents them.
Look for PK8's Self data suite, it's on the master script list.

Those scripts should do what you want - they add self switches, self variables and meta data to everything from actor to maps.
Those scripts look great, but they're not really the best to learn from! How about if I go with a simpler goal? Let's say I wanted to understand how to add another piece of data to the game, a Hash for example. There are several considerations from what I can see:

  1. On starting a new game, I'd like this Hash to be initialized, using a Hash I'd setup in a Module somewhere.
  2. On saving, I'd need this Hash to be saved alongside all other data.
  3. On loading a saved game, I'd need to make sure that game's Hash is loaded properly
From what I can gather, it would seem 2 and 3 involve aliasing some method(s) within DataManager. For 1, I guess it's just attaching initialization code to whatever handles setting up a new game. Any pointers for achieving this would be great, so I can understand how this is done for myself, and add that knowledge to my own attempts at scripting.  🙂

EDIT: I should probably then also change the thread title to reflect this?
Here is a simple example

http://himeworks.wordpress.com/2013/08/19/party-manager/

module DataManager class << self alias :th_party_manager_create_game_objects :create_game_objects alias :th_party_manager_make_save_contents :make_save_contents alias :th_party_manager_extract_save_contents :extract_save_contents end def self.create_game_objects th_party_manager_create_game_objects $game_parties = Game_Parties.new end def self.make_save_contents contents = th_party_manager_make_save_contents contents[😛arties] = $game_parties contents end def self.extract_save_contents(contents) th_party_manager_extract_save_contents(contents) $game_parties = contents[😛arties] || Game_Parties.new endendNote the initialization in the load method.Best practice for savefile compatibility: anything you write in `create_game_objects` or `setup_new_game`, which are called when starting a new game, should also be done in `extract_save_contents`
Thank you very much! So the game contents are essentially a Hash, and handling new 'global data' means adding a new key? Also...

class << self alias :th_party_manager_create_game_objects :create_game_objects alias :th_party_manager_make_save_contents :make_save_contents alias :th_party_manager_extract_save_contents :extract_save_contentsendThis is just for neatness' sake, organising alieses, or is something else going on here?

Again, thanks for the example, I'll have a play.
Those are class methods so you need to alias the class methods, not instance methods.

Code:
module DataManager  alias :my_test_method :test_method  def self.test_method    my_test_method    p 'new stuff'  endend
Would not do what you want.
Ta mucho, I guess this thread can be considered closed!  😀

Original thread: https://forums.rpgmakerweb.com/threads/adding-persistent-data-how-to-use-datamanager.17133/