Hello, all! I'm somewhat of a novice when it comes to scripts and forums and the like, so I'll try to be blunt.
I've been developing a VN (visual novel) type game with RPGMaker VX Ace, with Galv's visual choices and Yanfly's save engine. Working with existing scripts and patching some lines of code, I created a way to open the game menu while a message is on the screen. This part works flawlessly.
However, there is a dilemma with saving the game—specifically with a choice list window open. Message windows alone actually save and load just fine, but the game refuses to save when a choice dialog is open. I had a feeling I would run into a problem like this, but I have no clue where to start with scripting to get a save to work. I've browsed the system scripts myself, and can't seem to find what could be preventing the save from occurring. Any help would be appreciated.
Info I have so far:
I made the script console print each value of DataManager.make_save_header and .make_save_contents, as well as a "Save success/fail" file, and the result is that the save header is made with each value, but the save contents don't print anything except the "save fail" code.
and how can you save when having the choice window open?
usually for opening the menu you close the choice window first, and that defaults to the cancel branch.
I created a script of my own to open the menu while choices are open. It doesn’t work unless the cancel option in the event is set to “disallow.” As mentioned, the menu opens just fine. The issue I need help with is with the save.
Wouldn't it be easier to activate the autosave feature (speaking of a brand new feature here) than letting the player save during a choice window?
I was unaware that RMVXA had autosave. That would technically work, but I’d prefer to have a method of players being able to save before making big decisions, so they can load if they aren’t sure of the result.
How would one go about activating the autosave feature?
I meant, you'd have to implement a brand new feature, the autosaving of game sessions, even if that was not intended as an integral part of your project.
Oh, I see now. Well, in either case, I'd have to find out what is preventing the game from saving while a choice window is open. That's really the main issue I'm having—I'm sure activating an autosave while the window is open could also result in the same bug.
After some continued research of my own into this issue, I fear that my problem could be related to an "incompatibility between Marshal (the code the game's save/load uses) and Fiber (the game's process for waiting for a message to type or, in this case, a choice to be called.)"
Unfortunately, I don't even know where to begin with scripting a fix for this, so I'm definitely in need of a lead. Any help appreciated.
I truly suspect that we would need to see what changes you've made so far concerning the saving feature and messages. Otherwise we could easily end up telling you to overwrite some of your own code, invalidating some of its current features.
My way of handling it would be to forget about displaying the choice window WHILE the menu scene is active on screen.
EDITED
The easiest way I could think off is to call the next menu as usual. This will allow you to keep the old scene paused or "not updated" while saving the game session. THEN before exiting the menu, you would need not to call the Scene_Map again, instead use SceneManager.return then.
And please don't double post. It's against the rules.
I already have the key call the menu using SceneManager.call(scene), and I use the SceneManager.return method as well, I just overwrite it with an instant text enforcer so the message doesn’t start over typing out when the game is resumed and instead prints all at once, since that’s how it appears when the menu is called.
My issue, from what I can tell, is how to make the save method—which uses Marshal.dump()—compatible with the message system’s Fiber, or at least a way to save and resume its processing on command. I read in one of the comments of the DataManager module in the default scripts that “Marshal is incompatible with Fiber,” leading me to that conclusion.
Edit: Responding on my phone so if I misnamed a method I apologize
Out of curiosity, are you adding anything to the .make_save_contents or .make_save_header, like, saving the window itself?
I have not tried that, actually, but I’m not sure how well it would work, since the message and choice window is a part of the Game_Map class, which is saved. I’m also only a novice when it comes to scripting, so I don’t even know where to begin.
I believe Yanfly’s engine, linked above, modifies the .make_save_header code so it can show more stuff on the save file in the menu, but that’s the only modification to that thus far.
What I’ve gathered is the game really shouldn’t be trying to save with the choice window open, so for now I’ll just modify part of the script I posted to disallow pausing the game while there are choices and add some kind of tell that the player should take their opportunity to save.
Woah, that one gave me a lot more information. Thank you.
Two message boxes appeared, first was "Failed to dump Game_Message," followed by "Failed to dump @choice_proc." The console also prints a bunch of variables, some from my other scripts, which for some reason I previously deemed unrelated, which was likely a mistake.
I see "@choice_proc -- proc" in the console, I'm assuming that must be a variable and type which is incompatible with Marshal.
Edit: Knowing that, I need to find a way of either making it somehow saveable and loadable, or purge the variable in a way that can be restored when the menu is closed or the scene is loaded, in the same way that the message restores itself
Will that work even across game sessions, I.e., closing the game and loading the save? If so, that’s perfect and it’s all I needed.
Oh goodness, thank you so much! The patch works flawlessly, and it seems relatively simple as well. I'm able to save and load from an opened choice window perfectly! You're a lifesaver.
Edit: On second thought, I just tested loading the save. It opens the choice window as intended, but when an option is chosen it does not execute the branch.
Edit 2: After additional testing, I found that once a choice is confirmed after load, it simply closes out event processing completely. I'm looking into it to see what it could be doing. I forgot to save oops
Edit 3: I could be wrong, but I believe the branch and index aren't being saved. I'm not entirely sure how to go about doing that, and I'm open to suggestions. I'll try some experiments on my own in the meantime.