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.

how to save/load by calling a script through an event?

here's the deal, i'm an eventer. i event everything from my battle systems, to my menus, and even my title screen. however, there is NO WAY to event my own save/load screen given the nature of rmxp having a pre-programmed screen for loading/saving and not having any events to just save/load. needless to say, i wanna event it anyway. but there's a problem here.

i don't know jack-shit about scripting, so i need help with this.

what i'm asking is if there's a scrap of code i could just call through an event that would just force a save on the first save slot, and another to load the game from the first slot. this way i can call it from an event-based menu, and it will just save on the first save-slot. if there's already a save game on this slot, it needs to just be over-written automatically.

additionally, yet slightly less important, if there would be a way to call yet a third code in a conditional branch (apparently you can have a condition branch check if 'ruby code snippet' is true, which i never knew until just now) to check if there's a save file on the first slot, and cause the conditional branch to return a 'yes' if the slot is occupied, this would be pretty helpful too.

what i'm going for is just a 'new game' / 'continue game' scenario. thanks in advance to anyone who may be able to help me.
 

Zeriab

Sponsor

There certainly is ^^
Here are two snippets for saving the game. (The difference being whether the save sound effect being played or not)
Save with the sound effect being played:
Code:
$game_temp.save_calling = true
s = Scene_Save.new
s.on_decision('Save1.rxdata')

Save without the Save SE being played:
Code:
s = Scene_Save.new
file = File.open('Save1.rxdata', "wb")
s.write_save_data(file)
file.close

For load I likewise will present you with two snippets.
Load with Load SE:
Code:
l = Scene_Load.new
l.on_decision('Save1.rxdata')

Load without Load SE:
Code:
l = Scene_Load.new
file = File.open('Save1.rxdata', "rb")
l.read_save_data(file)
file.close
$game_system.
  bgm_play($game_system.playing_bgm)
$game_system.
  bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new

All of the snippets here can be placed in a script call.
Finally you can place this code in script section of the conditional branch to check whether there exist an save file in slot 1 or not:
Code:
FileTest.exist?('Save1.rxdata')

I hope you will be able to work out the rest yourself
*hugs*
- Zeriab
 

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