saving and loading

vindaca

CEO of Tales of the Valiant
Veteran
Joined
Dec 11, 2012
Messages
534
Reaction score
75
First Language
English
Primarily Uses
Well as of right now the script works and is fully functional.(Almost)

Where and how could I go about saving the new weapons? I have never had to save and load data directly like this.

Code:
   #-----------------------------------------------------------------------------  # * Create Weapon  #-----------------------------------------------------------------------------  def create_weapon(id, prefix = false, suffix = false)    base = Marshal.load(Marshal.dump($data_weapons[id]))    prefix = create_prefix(base) if prefix == false    suffix = create_suffix(base) if suffix == false    base.id = $data_weapons.size    base.name = create_name(base, prefix, suffix)    base.params = create_params(base, prefix, suffix)    base.features = create_feats(base, prefix, suffix)    base.price = create_price(base, prefix, suffix)    $data_weapons.push base    $game_party.gain_item($data_weapons[$data_weapons.size - 1], 1, true)  end 
 
Last edited by a moderator:

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
For your affix script right?  I tinkered with it a bit, there are a few different ways of going about it I think, here's my attempt.

module DataManager class << self alias :vindaca_affixes_esc :extract_save_contents alias :vindaca_affixes_cgo :create_game_objects end def self.extract_save_contents(contents) vindaca_affixes_esc(contents) #Appends new arrays to the armor/weapon database. $data_armors.concat($game_system.affixed_armors) $data_weapons.concat($game_system.affixed_weapons) end def self.create_game_objects vindaca_affixes_cgo #Insures new games start with fresh databases, in cases of exiting a saved #game and going directly to a new game, instead of closing the game first. load_database endendclass Game_System #New arrays just for the new weapons/armor saving/loading attr_accessor :affixed_armors, :affixed_weapons alias :vindaca_affixes_gs_init :initialize def initialize vindaca_affixes_gs_init @affixed_armors = @affixed_weapons = [] endendclass Game_Interpreter #----------------------------------------------------------------------------- # * Create Weapon #----------------------------------------------------------------------------- def create_weapon(id, prefix = false, suffix = false) base = $data_weapons[id].dup prefix = create_prefix(base) if prefix == false suffix = create_suffix(base) if suffix == false base.id = $data_weapons.size base.name = create_name(base, prefix, suffix) base.params = create_params(base, prefix, suffix) base.features = create_feats(base, prefix, suffix) base.price = create_price(base, prefix, suffix) $data_weapons.push base #Add to new array $game_system.affixed_weapons.push base $game_party.gain_item($data_weapons[$data_weapons.size - 1], 1, true) end #----------------------------------------------------------------------------- # * Create Armor #----------------------------------------------------------------------------- def create_armor(id, prefix = false, suffix = false) base = $data_armors[id].dup prefix = create_prefix(base) if prefix == false suffix = create_suffix(base) if suffix == false base.id = $data_armors.size base.name = create_name(base, prefix, suffix) base.params = create_params(base, prefix, suffix) base.features = create_feats(base, prefix, suffix) $data_armors.push base #Add to new array $game_system.affixed_armors.push base $game_party.gain_item($data_armors[$data_armors.size - 1], 1, true) endendI'm sure someone will come around with another possible solution, such as saving/loading them into their own spots within make_save_contents/extract_save_contents instead of $game_system like I did.Edit: The following are the 2 main methods for saving and loading save files that you need to concern yourself with. I added it my save addition as part of $game_system so I didn't have to do anything under make_save_contents. I did however have to maker sure that what I saved was properly loaded to be used correctly, hence the addition to extract_save_contents.

module DataManager #-------------------------------------------------------------------------- # * Create Save Contents #-------------------------------------------------------------------------- def self.make_save_contents contents = {} contents[:system] = $game_system contents[:timer] = $game_timer contents[:message] = $game_message contents[:switches] = $game_switches contents[:variables] = $game_variables contents[:self_switches] = $game_self_switches contents[:actors] = $game_actors contents[:party] = $game_party contents[:troop] = $game_troop contents[:map] = $game_map contents[:player] = $game_player contents end #-------------------------------------------------------------------------- # * Extract Save Contents #-------------------------------------------------------------------------- def self.extract_save_contents(contents) $game_system = contents[:system] $game_timer = contents[:timer] $game_message = contents[:message] $game_switches = contents[:switches] $game_variables = contents[:variables] $game_self_switches = contents[:self_switches] $game_actors = contents[:actors] $game_party = contents[:party] $game_troop = contents[:troop] $game_map = contents[:map] $game_player = contents[:player] endAs for the change in create_game_objects up above in the 1st spoiler, imagine starting a game, creating 5 affixed items, saving, and starting a new game, and creating 5 more. You normally wouldn't see a difference, but I used a small edit of item names to show item id's instead. The first 5 items created were fine, using id's after the last entry in the database. The last 5 items created on the other hand... had their id's start off as if the original 5 items were still part of the database. That's why I felt it necessary to "reload" the database at that point. There's no way of knowing if leaving it as is would have any undesired effects.Edit: Removed spoilers as they weren't working correctly for this post?
 
Last edited by a moderator:

vindaca

CEO of Tales of the Valiant
Veteran
Joined
Dec 11, 2012
Messages
534
Reaction score
75
First Language
English
Primarily Uses
Thank you Selchar. That worked, the funny thing is I tried that all already. I just forgot to alias the methods, so it was returning an error and so I decided to post this question. Thanks again.

"I'm sure someone will come around with another possible solution, such as saving/loading them into their own spots within make_save_contents/extract_save_contents instead of $game_system like I did."

This is what I was asking for, but this works perfectly. I will just use this method for now.

If anyone else can help, just for personal knowledge, how would one go about saving and loading them into there own spots.
 

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
Back again, I hastily added more info just after you're last post I believe, expanding a bit on the script I provided, here's a slightly altered version that uses global variables, and makes proper use of make_save_contents/extract_save_contents instead of appending it to $game_system like I did above. It's not hard at all if you look at the original methods to see what's going on.

Code:
module DataManager  class << self    alias :vindaca_affixes_msc :make_save_contents    alias :vindaca_affixes_esc :extract_save_contents    alias :vindaca_affixes_cgo :create_game_objects  end    def self.make_save_contents    #Original method into contents    contents = vindaca_affixes_msc    #global affix equip arrays into their own slots within    contents[:affixed_armors]        = $affixed_armors    contents[:affixed_weapons]        = $affixed_weapons    #return new contents    contents  end    def self.extract_save_contents(contents)    vindaca_affixes_esc(contents)    #Save data contents back into global arrays    $affixed_armors        = contents[:affixed_armors]    $affixed_weapons        = contents[:affixed_weapons]    #Appends new arrays to the armor/weapon database.    $data_armors.concat($affixed_armors)    $data_weapons.concat($affixed_weapons)  end    def self.create_game_objects    vindaca_affixes_cgo        #New global arrays for holding affixed equip data.    $affixed_armors = $affixed_weapons = []        #Insures new games start with fresh databases, in cases of exiting a saved    #game and going directly to a new game, instead of closing the game first.    load_database  endendclass Game_Interpreter  #-----------------------------------------------------------------------------  # * Create Weapon  #-----------------------------------------------------------------------------  def create_weapon(id, prefix = false, suffix = false)    base = $data_weapons[id].dup    prefix = create_prefix(base) if prefix == false    suffix = create_suffix(base) if suffix == false    base.id = $data_weapons.size    base.name = create_name(base, prefix, suffix)    base.params = create_params(base, prefix, suffix)    base.features = create_feats(base, prefix, suffix)    base.price = create_price(base, prefix, suffix)    $data_weapons.push base    #Add to new array for affixed weapons.    $affixed_weapons.push base    $game_party.gain_item($data_weapons[$data_weapons.size - 1], 1, true)  end    #-----------------------------------------------------------------------------  # * Create Armor  #-----------------------------------------------------------------------------  def create_armor(id, prefix = false, suffix = false)    base = $data_armors[id].dup    prefix = create_prefix(base) if prefix == false    suffix = create_suffix(base) if suffix == false    base.id = $data_armors.size    base.name = create_name(base, prefix, suffix)    base.params = create_params(base, prefix, suffix)    base.features = create_feats(base, prefix, suffix)    $data_armors.push base    #Add to new array for affixed armors.    $affixed_armors.push base    $game_party.gain_item($data_armors[$data_armors.size - 1], 1, true)  endend 
 

vindaca

CEO of Tales of the Valiant
Veteran
Joined
Dec 11, 2012
Messages
534
Reaction score
75
First Language
English
Primarily Uses
Ahhhhhh Ok..... I get it. Thank you Selchar.

But that brings me to a new question. Which way is better memory wise?
 

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
I honestly wouldn't know which way is the "best", but I did do a quick test, creating 10,000 weapons.


The 1st method I showed, adding it to $game_system, produced a save file of 1.27 megabytes for me.


The 2nd method I showed, using global arrays and adding them to their own spots, produced a save file of 1.58 megabytes.


I'm a bit surprised at the result... *redoes tests without randomizing affixes* 820kb vs 1083kb without afixes. It would appear that adding them to $game_system was the better options, tho I'm not entirely sure why that would be. Either it's the difference of an instance variable and a global variable, or increasing an existing class vs adding 2 more indexes to the hash used for saving data.


I hope someone with more experience provides more information, as I wasn't expecting that.


Edit: Applied the game_system method to Tsukihime's Instance Items, but the difference wasn't as noticeable for some reason. So... no idea.
 
Last edited by a moderator:

vindaca

CEO of Tales of the Valiant
Veteran
Joined
Dec 11, 2012
Messages
534
Reaction score
75
First Language
English
Primarily Uses
Can you do that again with this I want to see how the 2d array goes against the first setup
 

Yeah Tsuki's script is set up completly different. From what I understood doesn't actually create new weapons. I'm not really sure though I am still reading over it.
 
 
 

Code:
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>##                                                                              ##                           V's  Prefixes & Suffixes                           ##                                 Version  0.3                                 ##                                                                              ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##                                Written By:  V                                ##                         Last Edited: January 30, 2014                        ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##                                                                              ##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>##==============================================================================##------------------------------------------------------------------------------## ** Disclaimer                                                                ##------------------------------------------------------------------------------##                                                                              ## This script was intended for Non-Commercial use only, if you wish to use     ## this script in a commercial game please PM me at which ever site you found   ## this script. Either way please give me credit in your game script as the     ## writer of this script, and send me a PM abuot the release of the game/demo.  ##                                                                              ##------------------------------------------------------------------------------## ** How To Use                                                                ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##                                                                              ##  * Check out weapons numbers 1, 64, 65, 67, 68 in the demo for examples of   ##  how to set-up weapons, prefixes, and suffixes.                              ##                                                                              ##  * All prefixes, and suffixes are created the same way as weapons an must    ##  ALL be created as a weapon.                                                 ##                                                                              ##  * Armor is set-up with the same tag as weapon 1.                            ##                                                                              ##  * Place these tags in your Weapon or Armor Noteboxes, the # should be       ##  replaced by the weapon ids that you would like to use                       ##                                                                              ##       <Prefix: #, #, #>                                                      ##       <Suffix: #, #, #>                                                      ##                                                                              ##  * Use these commands in a script call to create a specific weapon or armor. ##                                                                              ##       create_weapon(base_weapon_id, prefix_id, suffix_id)                    ##       create_armor(base_armor_id, prefix_id, suffix_id)                      ##                                                                              ##  * The prefix_id and suffix_id are both false by default. A false id will    ##  result in a random prefix and suffex set-up via weapon and armor notetags.  ##  Here are a few more example script calls.                                   ##                                                                              ##       create_weapon(base_weapon_id, false, suffix_id)                        ##       create_weapon(base_weapon_id, prefix_id, false)                        ##       create_weapon(base_weapon_id, false, false)                            ##       create_weapon(base_weapon_id)                                          ##                                                                              ##       create_armor(base_armor_id, false, suffix_id)                          ##       create_armor(base_armor_id, prefix_id, false)                          ##       create_armor(base_armor_id, false, false)                              ##       create_armor(base_armor_id)                                            ##                                                                              ##  * You can also use 0 as an id to ensure no perfix or suffix is used. Here   ##  are a few example of how to use 0.                                          ##                                                                              ##       create_weapon(base_weapon_id, 0, false)                                ##       create_weapon(base_weapon_id, false, 0)                                ##       create_weapon(base_weapon_id, prefix_id, 0)                            ##       create_weapon(base_weapon_id, 0, suffix_id)                            ##       create_weapon(base_weapon_id, 0, 0) This will result in a base weapon. ##                                                                              ##       create_armor(base_armor_id, false, 0)                                  ##       create_armor(base_armor_id, 0, false)                                  ##       create_armor(base_armor_id, prefix_id, 0)                              ##       create_armor(base_armor_id, 0, suffix_id)                              ##       create_armor(base_armor_id, 0, 0)                                      ##                                                                              ##                                                                              ##                       See the demo for more examples                         ##                                                                              ##------------------------------------------------------------------------------## ** Description                                                               ##------------------------------------------------------------------------------##                                                                              ##  v0.1                                                                        ## ~=~=~=~                                                                      ##                                                                              ## In v0.1, this script allows you to create instance item with prefixes and    ## suffixes, completly random, or very specific.                                ##                                                                              #  #  v0.2                                                                        ## ~=~=~=~                                                                      ##                                                                              ## A few bug fixes were added and now all prices will be merged as well as the  ## parameters and features.                                                     ##                                                                              #  #  v0.3                                                                        ## ~=~=~=~                                                                      ##                                                                              ## A bug was found and fixed by Selchar. All armors and weapon are now saved.   ##                                                                              #  #------------------------------------------------------------------------------##==============================================================================##==============================================================================# ** DataManager#------------------------------------------------------------------------------#  This module manages the database and game objects. Almost all of the# global variables used by the game are initialized by this module.#==============================================================================module DataManager  #--------------------------------------------------------------------------  # * Aliasing Method: Extract Save Contents & Create Game Objects  #--------------------------------------------------------------------------  class << self    alias :vindaca_affixes_esc :extract_save_contents    alias :vindaca_affixes_cgo :create_game_objects  end   #--------------------------------------------------------------------------  # * Extract Save Contents  #--------------------------------------------------------------------------  def self.extract_save_contents(contents)    vindaca_affixes_esc(contents)    $data_armors.concat($game_system.affixed_items[1])    $data_weapons.concat($game_system.affixed_items[0])  end   #--------------------------------------------------------------------------  # * Create Game Objects  #--------------------------------------------------------------------------  def self.create_game_objects    vindaca_affixes_cgo    load_database  endend#==============================================================================# ** Game_System#------------------------------------------------------------------------------#  This class handles system data. It saves the disable state of saving and# menus. Instances of this class are referenced by $game_system.#==============================================================================class Game_System  #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------  attr_accessor :affixed_items  #--------------------------------------------------------------------------  # * Aliasing Method: Make Command List  #--------------------------------------------------------------------------  alias :vindaca_affixes_gs_init :initialize  #--------------------------------------------------------------------------  # * Initializing Processing  #--------------------------------------------------------------------------  def initialize    vindaca_affixes_gs_init    @affixed_items = []    @affixed_items.push []    @affixed_items.push []  end end#==============================================================================# ** Game_Interpreter#------------------------------------------------------------------------------#  An interpreter for executing event commands. This class is used within the# Game_Map, Game_Troop, and Game_Event classes.#==============================================================================class Game_Interpreter  #-----------------------------------------------------------------------------  # * Create Prefix  #-----------------------------------------------------------------------------  def create_prefix(base)    p_note = /<Prefix\S*\s*(\d+(?:\S*\s*\d+)*)+>/im    pre = base.note.match(p_note) {  $1.scan(/\d+/).collect { |i| i.to_i } }    unless pre == nil      prefix = pre[rand(pre.size)]      return prefix    else      return 0    end  end   #-----------------------------------------------------------------------------  # * Create Suffix  #-----------------------------------------------------------------------------  def create_suffix(base)    s_note = /<Suffix\S*\s*(\d+(?:\S*\s*\d+)*)+>/im    suf = base.note.match(s_note) {  $1.scan(/\d+/).collect { |i| i.to_i } }    unless suf == nil      suffix = suf[rand(suf.size)]      return suffix    else      return 0    end  end   #-----------------------------------------------------------------------------  # * Create Name  #-----------------------------------------------------------------------------  def create_name(base, prefix, suffix)    name = base.name    pre = $data_weapons[prefix].dup unless prefix == 0    suf = $data_weapons[suffix].dup unless suffix == 0    unless prefix == 0      name = pre.name + " " + name    end    unless suffix == 0      name = name + " " + suf.name    end    return name  end   #-----------------------------------------------------------------------------  # * Create Params  #-----------------------------------------------------------------------------  def create_params(base, prefix, suffix)    params = base.params    8.times {  |i| params[i] += $data_weapons[prefix].params[i] } unless prefix == 0    8.times {  |i| params[i] += $data_weapons[suffix].params[i] } unless suffix == 0    return params  end   #-----------------------------------------------------------------------------  # * Create Price  #-----------------------------------------------------------------------------  def create_price(base, prefix, suffix)    price = base.price    price += $data_weapons[prefix].price unless prefix == 0    price += $data_weapons[suffix].price unless suffix == 0    return price  end   #-----------------------------------------------------------------------------  # * Create Features  #-----------------------------------------------------------------------------  def create_feats(base, prefix, suffix)    feats = base.features    pre = $data_weapons[prefix] unless prefix == 0    suf = $data_weapons[suffix] unless suffix == 0    pre.features.each { |pf| feats.push pf } unless prefix == 0    suf.features.each { |sf| feats.push sf } unless suffix == 0    return feats  end   #-----------------------------------------------------------------------------  # * Create Weapon  #-----------------------------------------------------------------------------  def create_weapon(id, prefix = false, suffix = false)    base = Marshal.load(Marshal.dump($data_weapons[id]))    prefix = create_prefix(base) if prefix == false    suffix = create_suffix(base) if suffix == false    base.id = $data_weapons.size    base.name = create_name(base, prefix, suffix)    base.params = create_params(base, prefix, suffix)    base.features = create_feats(base, prefix, suffix)    base.price = create_price(base, prefix, suffix)    $data_weapons.push base    $game_system.affixed_items[0].push base    $game_party.gain_item($data_weapons[$data_weapons.size - 1], 1, true)  end   #-----------------------------------------------------------------------------  # * Create Weapon  #-----------------------------------------------------------------------------  def create_armor(id, prefix = false, suffix = false)    base = Marshal.load(Marshal.dump($data_armors[id]))    prefix = create_prefix(base) if prefix == false    suffix = create_suffix(base) if suffix == false    base.id = $data_armors.size    base.name = create_name(base, prefix, suffix)    base.params = create_params(base, prefix, suffix)    base.features = create_feats(base, prefix, suffix)    $data_armors.push base    $game_system.affixed_items[1].push base    $game_party.gain_item($data_armors[$data_armors.size - 1], 1, true)  end end
 
Last edited by a moderator:

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
I've been using your version 0.2 to do tests, so seeing as there's slightly more changes for your 0.3 than adding a save option, I thought it best to mention that... since I also deleted my copy of 0.2 to add your 0.3 version so I can't go back now to do a proper comparison.


2,196kb file size with 10,000 non-affixed Hand Axes.


I've been trying to help Tsukihime with ideas on how to reduce the size of save files, and Marshal dump/load was a topic of interest yesterday/today. I'm not sure it's best to create a deep copy of the entire item as it seems you're now doing, just of the necessities. I believe the bulk of the added data comes from making deep copies of the item description and item notebox, which I firmly believe should stay as reference only. That's my opinion anyways.
 

vindaca

CEO of Tales of the Valiant
Veteran
Joined
Dec 11, 2012
Messages
534
Reaction score
75
First Language
English
Primarily Uses
Thank you that helps a lot.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,358
Reaction score
7,671
First Language
German
Primarily Uses
RMMV
This is not directly about your questions here, but it is something you need to consider when writing scripts like these:


Game encryption


There are two sets of possible commands to access files from RM-Scripts, and one of them only works as long as you do not use encryption - it will return file not found as soon as that file is included in an encrypted game.


However, the automatic encryption will not place everything in the encrypted folder, which means that sometimes your own data remains outside the encrypted archieve (depends on file extensions).


There are ways around both problems (for example, SES external text creates the file for the archive and ignores the original text file on first playtest), but you should test whether your script works with encrypted games or not before finishing it.
 

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
Thanks for the reminder Andar, tho I don't think it's really a problem since we're adding to the default save file, still good to keep in mind in case one ever decides to create a completely new file.


After having fun with a 289 megabyte file size(filled up the description/notebox to the max with 10k items), I went back and redid my tests, description/notebox are completely empty and the rest of the default hand axe settings should be the same. If there was data in those fields then the full Marshal size would be higher.


With Marshal.load(Marshal.dump(item))


2D Array/$game_system: 1,689kb


Adding to save hash: 2,021kb


$game_system original: 1,591kb


With item.dup(fixed name/params/features/price to be marshaled in this case)


2D Array/$game_system: 1,591kb


Adding to save hash: 2,021kb


$game_system original: 1,591kb


Another unexpected result, we should stick to separate arrays for weapons/armor/items, and save in the $game_system object unless someone can give a good reason not to... Well that's the last piece of data I can offer for now so... night!


Oh, to do tests with your script creating 10000 of a single item, it's as easy as:


10000.times{


create_weapon(1, false, false)


}
 

vindaca

CEO of Tales of the Valiant
Veteran
Joined
Dec 11, 2012
Messages
534
Reaction score
75
First Language
English
Primarily Uses
I did as soon as I got back on my computer and thank you again Selchar. You've helped a lot. Laptops are nice when your away but if you can't test what your writing people like you help a lot. Thanks again.

@Andar~ Thank you and that is a very helpful tip. I will look into that. It is something that I will have to keep in mind for the future too.
 
Last edited by a moderator:

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,268
Reaction score
1,422
First Language
English
Primarily Uses
RMXP
You can compress your save files.

Lemme show pieces of some code I worked fairly long time ago for RMXP: First you need my StringBuffer class: http://pastebin.com/AaNrudWc

Next I defined two blocks, one for saving and one for loading:

class IntegrityError < IOError; end# Save a game along with its crc32 numberdef save_game_block(filename, *args, &block)  buffer = StringBuffer.new  block.call(buffer, *args)  crc32 = Zlib::crc32(buffer.data)  data = buffer.save(filename)  save_data(crc32, filename + '.crc')  end# Load the save game from the given filenamedef load_game_block(filename, *args, &block)  buffer = StringBuffer.new(filename)  data = buffer.data  crcfile = filename + '.crc'  crc_check = FileTest.exist?(crcfile)  if crcfile    old_crc32 = load_data(crcfile)    new_crc32 = Zlib::crc32(data)  else    raise ENOENT.new("#{filename} does not have an associated integrity file")  end  if old_crc32 == new_crc32    block.call(buffer, *args)  else    raise IntegrityError.new(filename)  endendI use the DEFLATE compression and my new block when I save the data. (This part looks significantly different for Ace)

    # Make the save data    raw_data = make_save_data    # Compress save data    save_data = Zlib::Deflate.deflate(raw_data)    # Write save data    save_game_block(filename) {|file|      Marshal.dump(System::VERSION, file)      Marshal.dump(@characters, file)      Marshal.dump(Graphics.frame_count, file)      Marshal.dump(save_data, file)    }My load_game_data block and decompress the save data. (This part also looks significantly different for Ace)

    # Read save data    data = nil    load_game_block(filename) {|file|      if Marshal.load(file).is_a?(String)        Marshal.load(file)      end      Marshal.load(file)      data = Marshal.load(file)    }    array = Marshal.load(Zlib::Inflate.inflate(data))    read_save_data(array)Hopefully it'll give you more inspiration.

P.s. if you want to do any encryption, remember to compress first, then encrypt.

*hugs*

 - Zeriab
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I'd love to implement whatever algorithm 7zip uses. It seems to do a much better job than deflate when I'm compressing my rvdata2 files.


But then again...serializing a lot of data takes a lot of time. Writing out lots of data takes a lot of time...it'd probably be too slow.

However, the automatic encryption will not place everything in the encrypted folder, which means that sometimes your own data remains outside the encrypted archieve (depends on file extensions).
All files/folders placed inside the Data or Graphics folders will be automatically encrypted. Everything else is ignored for the most part.


It depends on where you place your file, unless you are aware of a file extension that RM is instructed to ignore.
 
Last edited by a moderator:

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

Latest Threads

Latest Profile Posts

Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
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:

Forum statistics

Threads
105,854
Messages
1,017,004
Members
137,562
Latest member
tamedeathman
Top