Hi people!
I have some problems with my plugin. I have a global object, that is a parameter from the plugin:
Eli.HelpWindows.Param.menuHelp.text > This return to me various objects with string values.
I have an option that can change this string values via script calls or plugin commands. I was using this: Eli.HelpWindows.Param.menuHelp.text["object"] = "anything".
But this saves globally and if another new Game is chosen, the value will be from the other game.
So to avoid this, I alias the Game_System.prototype.initialize and create a new object that carries the parameters of the plugin:
Then, instead of using the value from Eli.HelpWindows.Param.menuHelp.text I used the $gameSystem._menuHelp.text to set and change the values.
In my tests, I start a new game and change the value via script call:
Then I save the game via menu command.
When I go to the title(via menu>game end) and start a new game, the value remains the one that I have changed via script call in the other save slot.
BUT!
If I go to game Title pressing F5 and start a new game, the value returns to its default. And in the save file, the value is as changed in the script call.
I make the same test with a game variable value, and when I start a new game it is immediately and automatically set to 0.
I take a look at the Rpg_managers and I see that the game objects are created in DataManager.setupNewGame() that I think that is called in Start New game command.
The DataManager.setupNewGame() create both Game_System Objects and Game_Variables objects. So why is the Game_System the value is not reset automatically at a New Game Start and in Game_Variables, the value is reset?
What I'm missing?
[EDIT] I have tried to use:
this._menuHelp.text = Eli.HelpWindows.Param.menuHelp.text;
this._menuHelp.text = {...Eli.HelpWindows.Param.menuHelp.text};
this._menuHelp.text = Object.assign({}, Eli.HelpWindows.Param.menuHelp.text};
But no work.
The only method that is working is this one:
this._menuHelp.text = JSON.parse(JSON.stringify(Eli.HelpWindows.Param.menuHelp))(made a deep copy).
Now it works properly. But I still don't get it why Mv behave like that.
I have some problems with my plugin. I have a global object, that is a parameter from the plugin:
Eli.HelpWindows.Param.menuHelp.text > This return to me various objects with string values.
I have an option that can change this string values via script calls or plugin commands. I was using this: Eli.HelpWindows.Param.menuHelp.text["object"] = "anything".
But this saves globally and if another new Game is chosen, the value will be from the other game.
So to avoid this, I alias the Game_System.prototype.initialize and create a new object that carries the parameters of the plugin:
JavaScript:
Eli.HelpWindows.Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
Eli.HelpWindows.Game_System_initialize.call(this);
this._menuHelp.text = Eli.HelpWindows.Param.menuHelp.text;
};
In my tests, I start a new game and change the value via script call:
JavaScript:
$gameSystem._menuHelp.text["object"] = "Hello world";
When I go to the title(via menu>game end) and start a new game, the value remains the one that I have changed via script call in the other save slot.
BUT!
If I go to game Title pressing F5 and start a new game, the value returns to its default. And in the save file, the value is as changed in the script call.
I make the same test with a game variable value, and when I start a new game it is immediately and automatically set to 0.
I take a look at the Rpg_managers and I see that the game objects are created in DataManager.setupNewGame() that I think that is called in Start New game command.
The DataManager.setupNewGame() create both Game_System Objects and Game_Variables objects. So why is the Game_System the value is not reset automatically at a New Game Start and in Game_Variables, the value is reset?
JavaScript:
DataManager.createGameObjects = function() {
$gameTemp = new Game_Temp();
$gameSystem = new Game_System();
$gameScreen = new Game_Screen();
$gameTimer = new Game_Timer();
$gameMessage = new Game_Message();
$gameSwitches = new Game_Switches();
$gameVariables = new Game_Variables();
$gameSelfSwitches = new Game_SelfSwitches();
$gameActors = new Game_Actors();
$gameParty = new Game_Party();
$gameTroop = new Game_Troop();
$gameMap = new Game_Map();
$gamePlayer = new Game_Player();
};
DataManager.setupNewGame = function() {
this.createGameObjects();
this.selectSavefileForNewGame();
$gameParty.setupStartingMembers();
$gamePlayer.reserveTransfer($dataSystem.startMapId,
$dataSystem.startX, $dataSystem.startY);
Graphics.frameCount = 0;
DataManager.makeSaveContents = function() {
// A save data does not contain $gameTemp, $gameMessage, and $gameTroop.
var contents = {};
contents.system = $gameSystem;
contents.screen = $gameScreen;
contents.timer = $gameTimer;
contents.switches = $gameSwitches;
contents.variables = $gameVariables;
contents.selfSwitches = $gameSelfSwitches;
contents.actors = $gameActors;
contents.party = $gameParty;
contents.map = $gameMap;
contents.player = $gamePlayer;
return contents;
};
};
What I'm missing?
[EDIT] I have tried to use:
this._menuHelp.text = Eli.HelpWindows.Param.menuHelp.text;
this._menuHelp.text = {...Eli.HelpWindows.Param.menuHelp.text};
this._menuHelp.text = Object.assign({}, Eli.HelpWindows.Param.menuHelp.text};
But no work.
The only method that is working is this one:
this._menuHelp.text = JSON.parse(JSON.stringify(Eli.HelpWindows.Param.menuHelp))(made a deep copy).
Now it works properly. But I still don't get it why Mv behave like that.
Last edited:

