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.
Adding persistent data, how to use DataManager
Learning Ruby and RGSSxLook 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 should do what you want - they add self switches, self variables and meta data to everything from actor to maps.
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.
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:
- On starting a new game, I'd like this Hash to be initialized, using a Hash I'd setup in a Module somewhere.
- On saving, I'd need this Hash to be saved alongside all other data.
- On loading a saved game, I'd need to make sure that game's Hash is loaded properly
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`
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.
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.
Would not do what you want.
Code:
module DataManager alias :my_test_method :test_method def self.test_method my_test_method p 'new stuff' endend
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/