Is there an easy way to detect if a game was loaded (Continued) in a javascript plugin?
Detect 'continue' from saved game in javascript?
Javascript/Plugin SupportWhy do you need it for?
You can do this : if user clicks new game, then your first event in game has Control Switches and set some switch to ON.
That indicates the game has started.
From plugin, you access in-game switches with
So, if you previously set switch #0001 to ON, then you'll type
You can do this : if user clicks new game, then your first event in game has Control Switches and set some switch to ON.
That indicates the game has started.
From plugin, you access in-game switches with
Code:
$gameSwitches.value(switchID)
Code:
$gameSwitches.value(1)
I think Terrax wants an event trigger every time a user loads a save file not when starts a new game.
If you make a custom js and paste this block of code: (it's in rpg_managers.js line 375)
DataManager.loadGameWithoutRescue = function(savefileId) { var globalInfo = this.loadGlobalInfo(); if (this.isThisGameFile(savefileId)) { var json = StorageManager.load(savefileId); this.createGameObjects(); this.extractSaveContents(JsonEx.parse(json)); this._lastAccessedId = savefileId; do your magic here return true; } else { return false; }}Then you can set a switch to ON from JS e.g. "GameContinued" and do whatever you want to do with it then switch back it off again so when the player saves the game and loads it again this switch state changing will trigger your events again.
There might be a better way to do it, but it works for my plugin which uses this same "is the player loaded a save file?" principle so it should work for you 🙂
If you make a custom js and paste this block of code: (it's in rpg_managers.js line 375)
DataManager.loadGameWithoutRescue = function(savefileId) { var globalInfo = this.loadGlobalInfo(); if (this.isThisGameFile(savefileId)) { var json = StorageManager.load(savefileId); this.createGameObjects(); this.extractSaveContents(JsonEx.parse(json)); this._lastAccessedId = savefileId; do your magic here return true; } else { return false; }}Then you can set a switch to ON from JS e.g. "GameContinued" and do whatever you want to do with it then switch back it off again so when the player saves the game and loads it again this switch state changing will trigger your events again.
There might be a better way to do it, but it works for my plugin which uses this same "is the player loaded a save file?" principle so it should work for you 🙂
Example, my plugin has a counter that keeps track of time of day running from 0 to 23. After every 'hour' that passes the
variable i stored inside a game-variable. When a game is saved, this game-variable is saved as well.
Now when a game gets loaded (continued) i need to get that game-variable and restore the hour into my own plugin variable..
I was wondering if there was some game-boolean that is thrown when a game gets loaded.
Oh, I thought you meant to check if it's continued or it started a new game...
When you enter the map, Game_Map.prototype.setup is called, so if you want to store your game variable as an plugin variable you would do that in that method.
If it's just loaded, not continued, you would check if $gameVariables.value(your time variable iD) is null or undefined or 0.
When you enter the map, Game_Map.prototype.setup is called, so if you want to store your game variable as an plugin variable you would do that in that method.
If it's just loaded, not continued, you would check if $gameVariables.value(your time variable iD) is null or undefined or 0.
Original thread: https://forums.rpgmakerweb.com/threads/detect-continue-from-saved-game-in-javascript.50332/