Load game script call?

Hey guys. So this may be something simple but I've looked everywhere and can't find anything. I 'm creating an menu screen through events and currently working on the load game function. I've set up an interactive menu through pictures and switches and I need to make an event that when the player presses the enter button it will load a certain save file. I'm only looking to use 3 save files using a conditional branch (script call button press) if possible.

In short how can I program "load file A" into a simple conditional branch.

Thanks for reading and your time.
If you're literally just trying to load a single file (as it exists on your computer), you can use a command similar to the following:

$data_actors = load_data("Data/Actors.rvdata2")The left hand side should be an object (such as $data_actors or a custom object like $external) and the right hand side should be load_data("x") where x is the directory and name of the file inside your main project folder.  Be careful about encrypting your project - only certain folders (such as "System") will be accessible once you do encrypt it.

However, I think that what you're trying to do here is to replicate all of the system's default "Load" behavior for when you select a game file to load.  I cobbled together a few methods from the Scene_Load class to come up with what you see below, and I imagine it will work but I don't have time to test it now.  I think it will do what you need (the main legwork is being done by the DataManager's load_game method), but just to be safe, I recommend you start a new, clean, "dummy" project and thoroughly test this script with it first because it's always risky to play around with existing saved data.

if DataManager.load_game(@index) Sound.play_load SceneManager.scene.fadeout_all $game_system.on_after_load SceneManager.goto(Scene_Map) else Sound.play_buzzer endThis is intended for insertion into any event in the game.  If you want to add it to a Scene in the script editor (rather than an event on a map or a common event), then you should replace the SceneManager.scene.fadeout_all lines with simply fadeout_all  .

EDIT: Per post #4, it looks like the above does work.  However, @index is obviously not defined inside an event on the map, so you should replace it with the appropriate number (0 for File #1, 1 for File #2, 2 for File #3, etc.).
DataManager.load_game(x)
Sound.play_load

SceneManager.scene.fadeout_all

$game_system.on_after_load
SceneManager.goto(Scene_Map)

Where x is the number of your save file - 1
 

Actually thank you for asking, because I wanted to use a similar feature too!
Thank you both for your answers. This has solved a problem that I've been dealing with for quite some time now. If anyone else stumbles upon this thread with the same problem then remember that file one's index equals 0. File 2 is 1 ect.
Glad it worked for you!

Nice catch on the @index - that was sloppy of me.  As you said, it should be replaced with the appropriate number since it's not defined inside an event on the map.
Might want to add a note:
 

If you load a savestate directly within an event, it won't cancel the frame update process the script command was executed in. The game will continue to update all (common-)events that were active before the load process.

However, if one of them affects game data (like a control variables command in a parallel process) it affects the recently loaded data instead.

It's unlikely something like this will happen, but as I don't know how the event menu is set up, it might not hurt to be aware of it.
(sorry for bump)

But will this work for XP?
No it will not. The code managing the save data loading is quite different and not very nice structured in XP.

I suggest adding this piece of code in a script section of it's own. As long as it's above Main it shouldn't matter where you place it.

class Interpreter  def load_game(file_num)    scene_load = Scene_Load.new    # File number is 1-based while file index is 0-based    filename = scene_load.make_filename(file_num - 1)    scene_load.on_decision(filename)    $game_temp.last_file_index = file_num - 1  end   def save_exist?(file_num)    scene_file = Scene_File.new('')    # File number is 1-based while file index is 0-based    filename = scene_file.make_filename(file_num - 1)    return FileTest.exist?(filename)  endend
To load save file 2 (Save2.rxdata) use the following script call

load_game(2)
To check whether Save2.rxdata actually exists use the following code in a Conditional Branch

save_exist?(2)
*hugs*

 - Zeriab
Maybe this was mentioned and I overlooked it, but is there a way to check for and load most recently saved file instead of just defining a specific file?
Look at how the default scripts decide which savefile to choose.
Use that logic for choosing which file to load.

Original thread: https://forums.rpgmakerweb.com/threads/load-game-script-call.38132/