RPG Maker Forums

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:

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;
};
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:
JavaScript:
$gameSystem._menuHelp.text["object"] = "Hello world";
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?

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. o_O

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,048
Messages
1,018,543
Members
137,834
Latest member
EverNoir
Top