MV TSR_Save.js problem

Hi I've been twerking TSR_Save.js for a day now and I cant seem to solve it. I have no programming backgrounds, even so I have no choice but to to check it anyway. I am thinking of using Bgs_MenusCancelCommand.js for mobile phone use.

So, basically, all I want is to go back to main menu after pressing "Cancel" when at save scene.
I ended up with 3 ideas but nothing is impressive enough:
1.SceneManager.push(Scene_Menu) - is wrong it will loop back to the save scene I do not know whats making this
2.SceneManager.goto(Scene_Menu) - answers my problem but has an issue that I have to click the return button twice to exit the menu which is annoying, but better
3.SceneManager.goto(Scene_Map) - alternative but it is not realistic to send the player directly from save scene back to map without passing main menu

Here is the part where I made changes, at line 2928 if I am not mistaken:

Scene_File.prototype.onConfirmCancel = function() {
if (TSR.Save.singleSlot && this.mode() === 'save') {

//SceneManager.push(Scene_Menu);

SceneManager.goto(Scene_Menu);

//SceneManager.goto(Scene_Map);

} else {
this._CommandWindow.close();
this._listWindow.activate();
this._listWindow.help.updatePosition(TSR.Save.help_x, TSR.Save.help_y);
this._listWindow.help.setText(this.HelpText());
this._listWindow.help.open();
if (this._listWindow._bitmapCursor) this._listWindow._bitmapCursorFixed = false;
}
};

Thank you for helping.
Keep in mind, if you cancel it from the save scene, you will go
to the map though, so why modification there?

what exactly is what you want to achieve as it already does it by default?

you could also apply to the thread as I modify and help people for their scene.

Now here is the thing:
I dont know how well it works on mobile, and cancel the scene probably require
a touch button "cancel/back" on scene load/scene save, as this is not needed
for pc users or maybe web users?

I dont know how mobile exactly works, but there is a plugin to add a "back button"
on each scene which might help you out, depending how cancel exactly work
on mobile, so I cannot really help you on that part.

I could however check out how it can work, but instead of "SceneManager.goto(Scene_Map);"
you can rather check if they are on "mobile device" like android, than add an option else
the default thing happens.

but while I cannot check if it does work on android, I cannot help you.
Here is what I am trying to achieve bro.
1. A clean menu where it contains stuffs including the TSR_Save.
2.What I want is make it to go back to main menu where I originaly came from before activating TSR_Save (for manual saving purposes if the player wants to) and not to send the player to the map directly
3.I haven't tried it yet with mobile, just saying I am planning to do it.
1) if you want to use a plugin for a different savefunction, you'll give us a link to the website of the plugin to check for options.

2) you're coming at it from the wrong direction.
instead of modifying the cancel/return function, you should try to change the calling function into a gosub functionality.
that way the cancel would autoreturn to the previous menu, but unfortunately I don't know enough of javascript to tell you how to do that.
1. https://forums.rpgmakerweb.com/inde...og-customize-the-save-and-load-screen.123611/

2. I do not understand anything you said about js sorry.
JS is harder, do you have a link to bgs_menucancelcommand?
so I can see what can mess with the scene and or add images
to what you want to achieve?

than I can try look into it and help you when able too.
it's easier for me to work on to modify the plugin if required.

Sorry, it is okay, thank you for helping me, do not put so much effort on it. With almost 2 days figuring it out, I am now giving up. I will just look for simple menus and won't ambition too much.
through the code, it should work, but based on its name and function,
you should place this plugin on the bottom (utility section) as it alias
function from menu, save, load, status, skill, etc.

if this is placed on top, it does not work, I can test later to confirm this
if you want me too, else I can try to impliment it for you.
but it should work on the bottom of your plugin list while TSR_Save needs to be
below YEP_CoreEngine.

if this plugin is higher than your save plugin, it does not work which why you
have trouble to make this work.

if it is below and you have this error, show a screenshot and I try to fix this
for you to read that function inside TSR_Save (this is no big trouble),
just give me a few days by than please.
Sad to say I am not using any Yanfly Plugins, I am not even sure anymore if this is fixable, I already made changes from rpg_managers.js rpg_scenes.js rpg_windows.js so it is a bit complicated now, and I can no longer track what is causing this to happen. I already did put the plugin up and down the plugin list, top most, bottom most, below or above suspected plugins. But nothing worked. So it is okay. Let's just give up on it.
if you directly change things inside rpg_manager, rpg_scenes etc,
than you are in bigger trouble than it should be.

YEP plugins are optional, no must, but if you made changes to its
core without knowing, it can break more stuff than you realize, which
why they "overwrite" or "alias" the function with the changes.

those plugins addings to your list = 10x safer and you wont break
anything to the core as well, so its an easier fix if you made change
on its core.

some people does that because they know what they do, specially
more advance coders does this.

but if you dont know what you do, its really bad, so its harder to track
down the cause and fix it (but its still fixable).

but to make sure the plugin does work, create a new project,
add TSR_Save and Bgs_MenuCancelCommand.

another very important note which I forgot to ask, is it called
"Bgs_MenusCancelCommand" (without quotes) because, if you
change the name, it wont read any parameters as well.

but the clean project can confirm it is added or not, if its not added,
than we can try to pinpoint where you went wrong.
Thanks for your help shadow dragon, I sincerely feel that you wanted to help. I made another solution for this and that is I made a map button that opens TSR_Save that way incase the player moves out of the save scene it will now go back to map scene directly.

Yes, I am so dumb and now regretting touching main core. But it can't be helped, I don't have any coding backgrounds and that time it was the best and fastest solution I can think of. Sad...
What about 'SceneManager.pop()'
What about 'SceneManager.pop()'
same effect as original this.popScene() needs double tap to exit menu
thats because this.popScene() exit the stack by 1, not 2.
so if you have Map => Main menu => Save Scene, than this.popScene exit the
save scene to Main Menu, pressing cancel use this.popScene() again to go
back to the map.

if you want from Save to Map while the Bgs_MenuCancelButton is added
to the save scene, than you need to modify that plugin, than on line
427 and 438, you can set of this.popScene() to SceneManager.goto(Scene_Map);

which than works if that plugin is installed, because that this.popScene is than
changed (if true) go to scene map), not in TSR_Save.

try that and see if that works 🙂

if Scene_Map does not work, I need to get the corresponding call to go there.
Thank you shadow dragon, I happen to solve it already by placing a map button for TSR_Save. Thanks a lot.
@jeromemanzon I know you said you solved it, but if you're interested in how I set it up through JavaScript, let me know and I'll share my result with you.

I will say that the 'OnConfirmCancel' function is called when the user cancels after selecting a slot to save to.
@jeromemanzon I know you said you solved it, but if you're interested in how I set it up through JavaScript, let me know and I'll share my result with you.

I will say that the 'OnConfirmCancel' function is called when the user cancels after selecting a slot to save to.
Thank you mate, for spending time on this problem. Yeah if you want to share what you've done, it would be nice because it maybe can help other people too who has the same problem. I appreciate you for putting some time despite your busy schedule, but right now I don't even think I could understand complex plugins. I might need that too in the future, although I am contented with what I have right now. So please share it here. Thanks a lot mate.
Here is what I did:

1. Change line 2785 from this:
this._listWindow.setHandler('cancel', this.popScene.bind(this));

To this:
this._listWindow.setHandler('cancel', this.onConfirmCancel_Custom.bind(this));

2. Go to line 2917 and press enter, then add the following code:
JavaScript:
Scene_File.prototype.onConfirmCancel_Custom = function () {
  if (this.mode() === 'save') {
    this.popScene();
    SceneManager.goto(Scene_Menu);
  } else {
    this._listWindow.close();
    this.popScene();
  }
};

Step one attaches a new function to the event handler that handles the cancel input from the list window.

Step two defines the new function.

Also note, I only tested this with the first 5 plugin parameters either all ON or all OFF, but it seems like everything was working properly. Let me know if you end up trying it.

Original thread: https://forums.rpgmakerweb.com/threads/tsr_save-js-problem.159552/