Adding persistent data, how to use DataManager

Sel Feena

All your VX Ace are belong to us
Veteran
Joined
Aug 10, 2013
Messages
35
Reaction score
0
First Language
English
Primarily Uses
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.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,669
First Language
German
Primarily Uses
RMMV
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.
 

Zechnophobe

Veteran
Veteran
Joined
Jul 17, 2013
Messages
93
Reaction score
2
First Language
English
Primarily Uses
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.
 

Sel Feena

All your VX Ace are belong to us
Veteran
Joined
Aug 10, 2013
Messages
35
Reaction score
0
First Language
English
Primarily Uses
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?
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
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[:parties] = $game_parties contents end def self.extract_save_contents(contents) th_party_manager_extract_save_contents(contents) $game_parties = contents[:parties] || 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`
 
Last edited by a moderator:

Sel Feena

All your VX Ace are belong to us
Veteran
Joined
Aug 10, 2013
Messages
35
Reaction score
0
First Language
English
Primarily Uses
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.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
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.
 
Last edited by a moderator:

Sel Feena

All your VX Ace are belong to us
Veteran
Joined
Aug 10, 2013
Messages
35
Reaction score
0
First Language
English
Primarily Uses
Ta mucho, I guess this thread can be considered closed!  :D
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,990
Members
137,562
Latest member
tamedeathman
Top