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 a file beffore shutdown.

Dko

Member

I was wondering how I where I would save a file if I wanted it done just before I completely quit from a game? Not during the time when the player would save there game. But when they quit the game all together. I specifically want to save $data_actors so a separate file of my choosing.

EDIT: never mind. I got my problem backwards. Im trying to have my game also load up my file at startup but it seams to not get a chance to do so.
 

Mac

Member

Put this code
Code:
    file = File.open(0, "wb")
    write_save_data(file)
    file.close

Under the the def command_shutdown in Scene_End
Code:
  def command_shutdown
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Fade out BGM, BGS, and ME
    Audio.bgm_fade(800)
    Audio.bgs_fade(800)
    Audio.me_fade(800)
    # Shutdown
    $scene = nil
  end
 
You could do an at_exit block. EXAMPLE:
Code:
def do_at_exit(str1)
  at_exit { print str1 }
end
at_exit { puts "cruel world" }
do_at_exit("goodbye ")
exit
produces:
Code:
goodbye cruel world
 
I recommend doing this. It seems to be more approripate in rmxp.

Go into Main. Below these lines:
Code:
  while $scene != nil
    $scene.main
  end

Add
Code:
  unless $game_system.nil?
    dummy = Scene_Save.new
    dummy.on_decision(dummy.make_filename(0))
  end
 
Sorry to bring this up again, but I too would like to do this. I have tried that way before Seph and it didn't do anything for me. But then again, I'm also trying to call the method AutoSave.save and I want it to execute when the process is exited, which is what Yeyinde is showing how to do, which doesn't work. So like when you close out the RGSS Player in anyway such as ending the process from the windows task manager or simply clicking the X in the top right corner of the window. Just wondering how I would accomplish this.
 

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