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.

[RESOLVED]Forced Save

Yin

Member

I tried to force a save using
file = File.open(filename, "wb")
write_save_data(file)
file.close
in a call script, but I keep getting a name error in the interpreter for the word filename. How exactly am I supposed to do this without using a full script. I only want it to force a save at the end of a chapter and when using certain items. So I don't really need a full script for this.
 
Code:
class Interpreter

  

  def force_save(filename)

    scene_save = Scene_Save.new

    file = File.open(filename + '.rxdata', 'wb')

    scene_save.write_save_data(file)

    file.close

    scene_save = nil

  end

end

To "force a save" in the file Save1.rxdata, type this:
Code:
force_save('Save1')
 
Try this script:
Code:
class Game_Temp

 

   attr_accessor :current_file

end

 

class Scene_Load

    alias sheol_ondecision on_decision

    def on_decision(filename)

        sheol_ondecision(filename)

        $game_temp.current_file = filename

    end

end

 

class Interpreter

  

   def force_save()

     scene_save = Scene_Save.new

     filename = $game_temp.current_file ? $game_temp.current_file : 'Save1'

     file = File.open(filename + '.rxdata', 'wb')

     scene_save.write_save_data(file)

     file.close

     scene_save = nil

  end

end
 

Yin

Member

I got an argument error when trying to call it. I used the same call.

EDIT: OH, ok I got it. I didn't need to put anything else but force_save. I'm going to test it in other slots too now.
EDIT AGAIN: Works! Thanks!
 

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