Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Question about where I went wrong...

James

Knight
Xy$
0.00
Greetings,


Thank you for taking a look at my post. I have a question about how to do something. I am trying to make a plugin that will work as a lives/respawn system. Basically I want when the game over scene starts to happen I want it to check a variable and if the variable is 1 or more then I want it to send you to a predefined location on that current map you are on, but if it is at zero I want it to do the normal game over. From my understanding of JavaScript is should go something along the lines of:


Game over Scene get aliased, after the party.isAllDead check is made check variable then the if else


But I cannot seem to make it work. I do not understand what I am doing wrong, I had a friend give me a template on overwriting/aliasing things and I followed it, but again I think I did it wrong. All I have managed is to make the check for the variable go in a loop and it constantly sends me to the cords I set. I can change the cords in the plugin manager and it sends me to the new cords, but I can’t get it to fire off when it calls the game over scene. I have tried every way I can think of , I will link the two ways that actually got results , I am asking if anyone can look at it and give me pointers as to where I went wrong and maybe point me to some reading materials or really good tuts so I can figure it out.

Here is a gif of what it is currently doing it is the only result that actually does anything:

https://gyazo.com/a86769c8651897bd6e1214d47b3bc87e





Code Version 1

JavaScript:
var parameters = PluginManager.parameters('BF_LivesRespawn');

var xcoord = Number(parameters['Xcoord'] || 1);

var ycoord = Number(parameters['Ycoord'] || 1);

var lives = Number(parameters['Lives'] || 20);
var _rewriteGameover = Scene_Base.prototype.checkGameover;
Scene_Base.prototype.checkGameover = function(args) {
  _rewriteGameover.call(this, args);
  if(lives >= 1)) {
    
       $gamePlayer.reserveTransfer($gameMap.mapId(), xcoord, ycoord, 6, 0);
     }
     else
     {
      SceneManager.goto(Scene_Gameover);
     }
      };

     
};






Code Version 2

JavaScript:
var parameters = PluginManager.parameters('BF_LivesRespawn');

var xcoord = Number(parameters['Xcoord'] || 1);
var ycoord = Number(parameters['Ycoord'] || 1);

var lives = Number(parameters['Lives'] || 20);


Scene_Base.prototype.checkGameover = function(args)
{
  myRespawn();
};

function myRespawn()
{
if(lives >= 1)
{
       
  $gamePlayer.reserveTransfer($gameMap.mapId(), xcoord, ycoord, 6, 0);
}
     else
  {
SceneManager.goto(Scene_Gameover);
  };
}
 

Nio Kasgami

Towns Guard
Xy$
0.00
it's because you simply not made the coding properly if you alias and put it before it's will still not work alias have to be done specifically depending the situation
and the second snipset...that's not even a code who would work...

JavaScript:
    (function(){
    var someAlias = Game_System.prototype.initialize;
    Game_System.prototype.initialize = function() {
    someAlias.call(this);
    this.liveStock = 5;
    };

    Game_System.prototype.increaseLife = function(value) {
    this.liveStock += value;
    };

    Game_System.prototype.decreaseLife = function(value) {
    this.liveStock -= value;
    };


    Scene_Base.prototype.checkGameover = function() {
    var lives = $gameSystem.liveStock;
    if(lives > 0){
        // do code here
        $gameSystem.decreaseLife(1);
    } else {
        SceneManager.goto(Scene_Gameover);
    }
    };

    })();
 

James

Knight
Xy$
0.00
So im aliasing it incorrectly, thank you , i will look more into how to do that properly. And thank you for your response.
 

James

Knight
Xy$
0.00
Honestly , no i have not gotten it working properly, i am still trying to learn JS , and i think that my lack of knowledge is the main issue , but for this plugin i have asked over on RMW, in one of the request workshops that someone write it , and they said they would , so im still working on JS , but this plugin will no longer be a issue for me .
 

eivl

Local Hero
Xy$
0.00
So you do not need any more help with this? is there anything else i can help you with? remember that RMMV uses oop in their code, so you might want to read about it after some basis JS coding tutorials.
 
Top