Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

save_data not really being a counterpart?

Load_data can load from archives.
save_data, it's counter_part should be able to save to archives, right?

Well it can't. Try to encrypt a game with:

Code:
save_data("hi","Data\Test.rxdata")
p load_data("Data\Test.rxdata")

It will fail at line two with an no such file exists, however, unecrypted it works fine.

I guess no-one knows how to do it then, right?
 
I didn't thought of that. Hmm.

Notice that, in the help file, we can read :

This function is essentially the same as:

File.open(filename, "rb") { |f|
obj = Marshal.load(f)
}

However, it differs in that it can load files from within encrypted archives.
save_data(obj, filename)
save_data($data_actors, "Data/Actors.rxdata")

This function is the same as:

File.open(filename, "wb") { |f|
Marshal.dump(obj, f)
}

The bold part might be the reason why it doesn't work.

I can't try that right now, but there's a few tests you could run :
- Does it change the rgssad filesize/checksum ?
- Does it create a file outside the rgssad if the directory exists ?
- What is its behaviour when erasing an already existing file ?
- What about not trying to use a directory ?

If you only want compression still, use a second Zlib archive which would take precedence over the rgssad in your scripts.
 
I will look into this, but I use this method in all of my scripts that require a text file to load data here is how I do it

Code:
  #--------------------------------------------------------------------------
  # * Main Database
  #--------------------------------------------------------------------------
  alias_method :trick_aibc_title_main_database, :main_database
  def main_database
    # The Usual
    trick_aibc_title_main_database
    # Setup Load Commands Flag
    @load_commands = true
    # Load Command Data
    load_command_data
    # If Load Commands Flag
    if @load_commands
      # IF Save Data Option
      if Battle_Command_Setup::Save_Data
        # Save a copy
        save_data($data_commands, "Data/Commands.rxdata")
      end
    # Project Encrypted
    else
      # Load from Data Commands 
      $data_commands = load_data("Data/Commands.rxdata")
    end
  end
  #--------------------------------------------------------------------------
  # * Battle Test
  #--------------------------------------------------------------------------
  alias_method :trick_aibc_title_battletest_database, :battletest_database
  def battletest_database
    # The Usual
    trick_aibc_title_battletest_database
    # Setup Load Commands Flag
    @load_commands = true
    # Load Command Data
    load_command_data
    # If Load Commands Flag
    if @load_commands
      # IF Save Data Option
      if Battle_Command_Setup::Save_Data
        # Save a copy
        save_data($data_commands, "Data/Commands.rxdata")
      end
    # Project Encrypted
    else
      # Load from Data Commands 
      $data_commands = load_data("Data/Commands.rxdata")
    end
  end
  #--------------------------------------------------------------------------
  # * Load Command Data
  #--------------------------------------------------------------------------
  def load_command_data
    # Setup Data Commands
    $data_commands = []
    begin
      # Get Data from Text File
      data = Trickster.load_data_from_txt("Data\\BattleCommands.rxdata", 
      Battle_Command_Setup::Line, [0,1,3], [], 2)
      # Run Through data loaded
      data.each_with_index do |command_data, index|
        # Create RPG::BattleCommand Object sending loaded hash as an argument
        $data_commands[index+1] = RPG::BattleCommand.new(command_data)
      end
    rescue Errno::ENOENT
      # project is encrypted or file not found
      @load_commands = false
    end
  end
 
- Does it change the rgssad filesize/checksum ?
- Does it create a file outside the rgssad if the directory exists ?
- What is its behaviour when erasing an already existing file ?
- What about not trying to use a directory ?
No; No; Error; I want it encrypted.

save_data($data_commands, "Data/Commands.rxdata")
Won't work if encrypted.

Notice that, in the help file, we can read :
My thoughts exactly, so that sucks.
 
Before I close this, It will work if the file is not in a folder that is encrypted

I tried this in a call script

Code:
save_data($data_commands, "Commands.rxdata")
p load_data("Commands.rxdata")

Encrypted it and it works, so I guess the error occurs which encrypted folders :-/

still pretty annoying
 
Trickster;204616 said:
Before I close this, It will work if the file is not in a folder that is encrypted

I tried this in a call script

Code:
save_data($data_commands, "Commands.rxdata")
p load_data("Commands.rxdata")

Encrypted it and it works, so I guess the error occurs which encrypted folders :-/

still pretty annoying

I never said saving the file would not work, I did say saving in the encrypted rgssad does not work. But yes, the above is correct.
 
Yep, tried here, and it saves the file on disk, not in the archive. Quite logical, in fact : how would it knows where to save ?

Anyway, we won't be able to put stuff into that easily...

On the other side, while it is a critical function for some scripts, 99.99% of the users will never use it, so I can understand the QA was pretty lax with it...
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top