Jump to content

Recommended Posts

I'm trying to design all of my game's menus using events and script calls rather than use any of the engine's default menu windows. Saving the game using script calls is easy (it seems), with script call: DataManager.save_game(x), but loading is proving more troublesome.

 

A bit of an overview of what I'm aiming for:

 

1. The player selects 'load' from an in-game menu.

 

2. Six boxes representing save slots appear.

 

3. A separate script call conditional branch checks each slot. For each one that already contains a save file, a 'SAVE FILE' icon appears. For each one that's empty, an 'EMPTY SLOT' icon appears.

 

4. The player can then navigate a cursor around the six slots and choose one to load from. This movement is tracked with a variable (if the cursor is on slot 1, the variable will = 1, etc).

 

5. They highlight a filled slot (which contains a save file) and press the 'select' button on their keyboard.

 

6. Let's say they want to load the file in save slot #5. They highlight the 5th slot, press 'select'. The game then loads the 5th save game data file.

 

 

In a nutshell: is there any way to use a script call in a conditional branch that checks if a save slot has a save file in it?

 

i.e. something like this:

____________________________________________

 

Check SAVE SLOT 1:

 

Conditional Branch:

 

script call: "Does Save01.rvdata2 exist?" (this is the scripting element I need help with)

 

THEN: show picture 'slot 1 full'

 

ELSE: show picture 'slot 1 empty'

 

 

Check SAVE SLOT 2:

 

Conditional Branch:

 

script call: "Does Save02.rvdata2 exist?"

 

THEN: show picture 'slot 2 full'

 

ELSE: show picture 'slot 2 empty'

 

 

etc.

 

____________________________________________

 

Also, is there a way to use a script call in an event to load a specific save file?

 

i.e. Slot 1 contains a save file (Save01.rvdata2 exists), player has highlighted and selected it:

____________________________________________

 

script call: "Load the saved game file in save slot 1"

____________________________________________

 

 

I'm happy to clarify anything here that doesn't make sense, or that I've worded poorly. Thanks in advance for your help folks.

Edited by Elder71

Share this post


Link to post
Share on other sites

What do you mean? The save slot once is in is called Save(slot #). rvdata2 or am I wrong?

 

And what exactly are you asking? Does the system just any old save or? Meaning, wut happens if u don't clarify which save? Does it not save at all?

Share this post


Link to post
Share on other sites

What do you mean? The save slot once is in is called Save(slot #). rvdata2 or am I wrong?

 

And what exactly are you asking? Does the system just any old save or? Meaning, wut happens if u don't clarify which save? Does it not save at all?

 

All I want to do is use a conditional branch to check if a save file exists and then load it, all using an event (not the load/save window)

Share this post


Link to post
Share on other sites

 

In a nutshell: is there any way to use a script call in a conditional branch that checks if a save slot has a save file in it?

 

Yes, this is what the Script box is for inside the Conditional Branch command (last option on Page 4). Any Ruby expression that evaluates to true in there will satisfy the branch condition.

 

As for the actual code to use, you ought to check how the default scripts do it. The relevant objects you will want to take a look at are the DataManager, Window_SaveFile and maybe Scene_File/Scene_Save/Scene_Load (but it does seem you already know the code for making a save file).

Share this post


Link to post
Share on other sites

Try to use
DataManager.load_game(index)
to load a game

and 

DataManager.load_header(index)
to check if a savefile exists or not

Share this post


Link to post
Share on other sites

Try to use

DataManager.load_game(index)

to load a game

and 

DataManager.load_header(index)

to check if a savefile exists or not

 

I *think* I've tried the DataManager.load_game(index) line before, but it threw the game into a continual loading loop where it loaded the file over and over again without end.

 

I'll give these a go and see if I can get something working.

 

EDIT

 

DataManager.load_header(index) worked perfectly (it seems) for checking if a save file exists or not. Thank you!

 

However, DataManager.load_game(index) sort of worked, but with some weird, glitchy results. There was a momentary fade in/fade out and the screen 'moved' down a tile or two. My character sprite was left standing exactly where he was (next to the event that contained the script). Using the arrow keys moves the screen around, but not the sprite, who stays where he was as though I'm controlling an invisible second character :S

 

Forgive my ignorance here (i know nothing about RGSS3 at all) - could it be that something else is needed script-wise to refresh everything in some way?

 

 

 

 

In a nutshell: is there any way to use a script call in a conditional branch that checks if a save slot has a save file in it?

 

Yes, this is what the Script box is for inside the Conditional Branch command (last option on Page 4). Any Ruby expression that evaluates to true in there will satisfy the branch condition.

 

As for the actual code to use, you ought to check how the default scripts do it. The relevant objects you will want to take a look at are the DataManager, Window_SaveFile and maybe Scene_File/Scene_Save/Scene_Load (but it does seem you already know the code for making a save file).

 

 

Is it likely to be one line or several that I'm looking for?

Edited by Elder71

Share this post


Link to post
Share on other sites

I can answer the graphical glitch, when you quit to menu. The game disposes all resources and they get "re-made" when you load game/start new game. Since you simply called load game the old instances was never disposed. This explains the character being stationed at the old location, (ghost resource if you will), and since there is already one instance of the character sprite the "new" character is not loaded.

 

The thing I don't get, is why the position is loaded 1-2 steps away from where it should be. Don't have ace on this computer so I can't take a look at the code until I get home.

 

Hope I could shed some light on the situation. ;)

Share this post


Link to post
Share on other sites

 

Is it likely to be one line or several that I'm looking for?

 

Do this enough and you'll quickly realize that "one line of code" often means one line that calls a several other lines of code somewhere else that calls more code and so on and so forth. In this case, the game certainly does use more than one line to load savefiles.

 

And "DataManager.load_game()" does not cause an infinite loop. It does, in fact, load the game exactly once. To be precise, your problem is not that the map is glitched, it's that the sprites are glitched which is something you will notice only occurs if your game was saved on the same map you loaded it on. The reason for that is... well, you'll see if you take a look at the default code.

 

Short answer is yes, you do need to refresh/reload some things. The default code will show you which ones.

 

@Cookie Ninja - Because it's only the sprites that glitch, not the whole map. In fact, if you try and replicate this, you will notice that moving parallel backgrounds are fine. You can even interact normally with the events that are meant to be there, if you know where they are supposed to be.

Edited by Traverse

Share this post


Link to post
Share on other sites

Try this set of commands then

 

fadeout_all
SceneManager.scene.terminate
DataManager.load_game(index)
$game_system.on_after_load
SceneManager.scene.main

Share this post


Link to post
Share on other sites

 

Try this set of commands then

 

fadeout_all
SceneManager.scene.terminate
DataManager.load_game(index)
$game_system.on_after_load
SceneManager.scene.main

 

 

I gave it a try - thanks for your continued efforts here.

 

Unfortunately, I got a crash.

 

NjTAvHE.jpg

 

For 'fun', here's a cap of the event itself, just in case I'm doing something obviously wrong:

 

LwNwQM1.jpg

 

(ps - this setup is for testing purposes, so I'm only handling one save file and save slot for now)

Share this post


Link to post
Share on other sites

...And this is why you don't just copy-paste code snippets blindly.

 

You need to be aware that all script calls that run in event commands (the script boxes in Control Variables and Conditional Branch, the Script Call command, ect.) execute through the Game_Interpreter object. In fact, all event commands are executed by Game_Interpreter - you can take a look at the script to see how they all work. 

 

That method "fadeout_all" Shiggy instructed you to use is likely the one that you see being used in Scene_Load or Scene_Title. It does not exist in Game_Interpreter, hence why you're getting the error. Error messages mean things - if you take a look at the line specified by the error, line 1411, you will see that this is part of the method that gets run to execute the Script Call event command.

 

In order to call that method through the Game_Interpreter, you will need to do it indirectly through the SceneManager in the same way Shiggy told you to call "terminate" and "main" on the scene.

Share this post


Link to post
Share on other sites

...And this is why you don't just copy-paste code snippets blindly.

 

You need to be aware that all script calls that run in event commands (the script boxes in Control Variables and Conditional Branch, the Script Call command, ect.) execute through the Game_Interpreter object. In fact, all event commands are executed by Game_Interpreter - you can take a look at the script to see how they all work. 

 

That method "fadeout_all" Shiggy instructed you to use is likely the one that you see being used in Scene_Load or Scene_Title. It does not exist in Game_Interpreter, hence why you're getting the error. Error messages mean things - if you take a look at the line specified by the error, line 1411, you will see that this is part of the method that gets run to execute the Script Call event command.

 

In order to call that method through the Game_Interpreter, you will need to do it indirectly through the SceneManager in the same way Shiggy told you to call "terminate" and "main" on the scene.

 

In fairness to myself, copy-pasting blindly was the only way I had of doing it.

 

Well, anyhow, SceneManager.scene.fadeout_all still only sort-of worked. It loaded the file, but not everything was as it was when I saved. I think I'll just bite the bullet and stick to the default load/save function. Because this way around, even if I get it working, looks like it'll be riddled with game-breaking bugs that I'll have no hope of fixing.

 

Thanks for all your help anyhow, everyone

 

EDIT

 

Right. Now. I seem to have it working with:

 

SceneManager.scene.fadeout_all

DataManager.load_game(0)

 

SceneManager.goto(Scene_Map)

 

EXCEPT that if I save with a switch ON, when I load that save file the switch is OFF and I can't figure out why. It only seems to affect one switch in particular; the others load exactly as they were. I'm digging around for answers, running tests and wotnot, but thus far I can't figure out why this switch is automatically OFF when I load up.

 

Question: If I have a parallel process event counting 1800 frames (wait 600 frames, wait 600 frames, wait 600 frames) and saved in the middle of that count, would the save file record where the event was up to? It's a common event, so changing maps shouldn't interfere with it, right?

Edited by Elder71

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted