Window instance blocks ingame saving?

Hello,


I hope this is the right section, but there's no MV section in Scripting, so...


Anyway, I'm trying to write a plugin that displays a book.


I'm basically displaying two windows in the current map scene, fill them with text, and eventually close the windows again.


The windows are derrived from Window_Base. It looks like this:


//Creates the pages on the map screen - call in Event using $gameSystem.createPages();
Game_System.prototype.createPages = function(){
this._windowBookPageLeft = new Window_BookPageLeft(0, 0);
this._windowBookPageRight = new Window_BookPageRight(RD.Param.windowWidth/2, 0);
SceneManager._scene.addChild(this._windowBookPageLeft);
SceneManager._scene.addChild(this._windowBookPageRight);
};

//Removes the pages - call in Event using $gameSystem.disposePages();
Game_System.prototype.disposePages = function(){
SceneManager._scene.removeChild(this._windowBookPageLeft);
SceneManager._scene.removeChild(this._windowBookPageRight);
};


Now here's the thing: as soon as I actually create an instance of one of the windows


this._windowBookPageLeft = new Window_BookPageLeft(0, 0);


I can no longer save in the game. Selecting save and choosing a save slot, I only hear the buzzer and nothing happens.


This also happens when I create an instance of any other window class, such as Window_Base or Window_Gold. As soon as I instantiate, saving is disabled.


Using the "change save access" content in the event to try and manually turn on saving again does not help either.


I don't understand what's going on here. Can anyone help? I'll attach the entire script to the post.

View attachment BooksAndScrolls.js
Well I'm on my phone, but looking at this briefly you look like you know what you're doing. In the data manager should be a function called saveGame or similar (not saveGameWithoutRescue, that gets called by saveGame). In that function should be a try { } catch { } block. In the catch block, where it plays the buzzer sound, display the error in the console window using console.log, and then try to open a window and save again. The error should tell us exactly why things are not working, and then we can figure things out from there.


EDIT: Now that I'm showered and looking at this again, chances are the error is that you can't save a window. Game_System is saved into a save file so it can be reloaded later, however I don't think windows are valid serializable (saveable) objects, so that's where the error is. It tries, it fails, it buzzes instead of crashes. 
Well I'm on my phone, but looking at this briefly you look like you know what you're doing. In the data manager should be a function called saveGame or similar (not saveGameWithoutRescue, that gets called by saveGame). In that function should be a try { } catch { } block. In the catch block, where it plays the buzzer sound, display the error in the console window using console.log, and then try to open a window and save again. The error should tell us exactly why things are not working, and then we can figure things out from there.


EDIT: Now that I'm showered and looking at this again, chances are the error is that you can't save a window. Game_System is saved into a save file so it can be reloaded later, however I don't think windows are valid serializable (saveable) objects, so that's where the error is. It tries, it fails, it buzzes instead of crashes. 



Huh? So basically, as soon as there is a


_window = new Window(0, 0);


something in the code somewhere that gets executed, saving becomes impossible? What do I need to do then? Can I clear this variable in my dispose function somehow?
There is a MV section in scripting - not inside the RGSS-scripts, but inside the javascript section because MV doesn't use ruby anymore


I've moved this thread to Learning Javascript. Please be sure to post your threads in the correct forum next time. Thank you.
You stored a window in the Game_System class, which is instantiated when a new game begins. Window objects, to my knowledge, cannot be saved, so once you set your windows into $gameSystem, saving will no longer work. Since you shouldn't need to duplicate the EXACT windows after loading, put the windows in Game_Temp and just rebuild them on loading a game. 
You stored a window in the Game_System class, which is instantiated when a new game begins. Window objects, to my knowledge, cannot be saved, so once you set your windows into $gameSystem, saving will no longer work. Since you shouldn't need to duplicate the EXACT windows after loading, put the windows in Game_Temp and just rebuild them on loading a game. 



You, Sir, are a genius. I put it in Game_Temp and call it using &gameTemp now. Everything works like a charm now. Thanks a lot!

Original thread: https://forums.rpgmakerweb.com/threads/window-instance-blocks-ingame-saving.62572/