Unknown Scene Error with Variables

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,282
Reaction score
106
First Language
Irish
Primarily Uses
N/A
I have made a simple variable like this:

var milenaSystem = Game_System.prototype.initialize;Game_System.prototype._numbervalue;Game_System.prototype.initialize = function() { milenaSystem.call(this); this._numbervalue = 3;}then made a new variable check at scene map:

Scene_Map.prototype.update = function() { this.updateDestination(); this.updateMainMultiply(); if (this.isSceneChangeOk()) { this.updateScene(); } else if (SceneManager.isNextScene(Scene_Battle)) { this.updateEncounterEffect(); } this.updateWaitCount(); Scene_Base.prototype.update.call(this); if ($gameSystem._numbervalue === 0) { SceneManager.goto(Scene_Gameover); }};When I decrease the variable _numbervalue until it reaches zero, it should go to Scene_Gameover but it just stays there and the game just stops, the sound is still playing, its just that the scene doesn't go to the scene I want. Anything went wrong?
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,695
Reaction score
928
First Language
English
Primarily Uses
N/A
Are there any errors...? What you've given us is not enough to debug the problem. We can't see how the number is changed.
 
Also, why have this
 

Game_System.prototype._numbervalue;when you already assign it a value in the initialize function? This is redundant, and therefore not needed.
 
Also, please give meaningful names to your variables. It will make your life, as well as that of anyone who helps you, easier. After looking at it, it seems clear enough that the purpose of the variable is a life counter, but it'd be better to explicitly state that as it's name. 
 
could you please better explain this?

but it just stays there and the game just stops
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,282
Reaction score
106
First Language
Irish
Primarily Uses
N/A
this is the whole plugin:

var milenaSystem = Game_System.prototype.initialize;Game_System.prototype.initialize = function() { milenaSystem.call(this); this._numbervalue = 3;}Scene_Map.prototype.update = function() { this.updateDestination(); this.updateMainMultiply(); if (this.isSceneChangeOk()) { this.updateScene(); } else if (SceneManager.isNextScene(Scene_Battle)) { this.updateEncounterEffect(); } this.updateWaitCount(); Scene_Base.prototype.update.call(this); if ($gameSystem._numbervalue === 0) { SceneManager.goto(Scene_Gameover); }};To make the $gameSystem._numbervalue changed, what I do is do this on a script call:



Yes, its a life meter. I'll do that the next time :)

What I wanted was for the scene to check the value of the life meter everytime, and since it is 3 at the beginning and when I change it, the game just stops working. The music is still playing and when I put a console.log or print something, the developer console plays it. I know that the game is still running, but my controls, are not. 
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,695
Reaction score
928
First Language
English
Primarily Uses
N/A
Is the event autorun or anything? That would continually run and prevent any input, though I suppose it wouldn't prevent the scene from changing. After the controls freeze, open the console and verify that the value of the variable is indeed 0.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,282
Reaction score
106
First Language
Irish
Primarily Uses
N/A
The event is an Action Button. This goes the same when I use Game_Variables instead of a new variable from Game_System. At first, this check is happening on Spriteset_Map, but it just does the same. I tried to print it in the console and the value says it is indeed 0. But this is where my problem lies. If it is 0, shouldn't it transport me to the Game Over scene?
 

Galv

Veteran
Veteran
Joined
Oct 1, 2012
Messages
1,186
Reaction score
1,143
First Language
English
Primarily Uses
N/A
Seems to only happen when you do it via an event. Testing it by other means using your code worked.

Another option is to make the check when the game already checks for gameover, such as:

Code:
(function() {	var milenaSystem = Game_System.prototype.initialize;	Game_System.prototype.initialize = function() {		milenaSystem.call(this);		this._numbervalue = 3;	}		var milenaPartyAlldead = Game_Party.prototype.isAllDead;	Game_Party.prototype.isAllDead = function() {		if ($gameSystem._numbervalue === 0) return true;		return milenaPartyAlldead.call(this);	};})();
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,282
Reaction score
106
First Language
Irish
Primarily Uses
N/A
Seems to only happen when you do it via an event. Testing it by other means using your code worked.

Another option is to make the check when the game already checks for gameover, such as:

(function() { var milenaSystem = Game_System.prototype.initialize; Game_System.prototype.initialize = function() { milenaSystem.call(this); this._numbervalue = 3; } var milenaPartyAlldead = Game_Party.prototype.isAllDead; Game_Party.prototype.isAllDead = function() { if ($gameSystem._numbervalue === 0) return true; return milenaPartyAlldead.call(this); };})();
This works, thanks! But the way I did it sounds weird though, I thought an easy way of checking like that would work. I suppose there was something wrong from doing it via the update scene...
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Check out SpokenWord- my text-to-speech plugin for RPG Maker MV!
just watched spacex launch. was awesome.
Jumping and gravitation 0.1 build - RPG Maker MV
Currently playing final fantasy 3 on DS. It's an old one but its a classic.

Forum statistics

Threads
97,956
Messages
948,110
Members
129,203
Latest member
mizz
Top