MV Problem with Scene Constructors

I was wondering about how to handle plugin code that doesn't properly create a scene. Specifically, I'm looking at Scene_MenuBase as an example and how to fix a case where the scene constructor doesn't exist in the code (well, it does but it's completely unusable and returns an error when the constructor is called.

As an example of what I need help with, the following code from the abandoned poker/card match plugin which I found over here is telling me that apply is not a part of an undefined reference, which if resolved may well provide a base to pick up from where the original author left off. Here's the scene constructor from the casino.js file that's a part of the plugin set:

JavaScript:
function Scene_Casino() {
    this.initialize.apply(this, arguments);
}

Scene_Casino.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Casino.prototype.constructor = Scene_Casino;

Scene_Casino.prototype.initialize = function () {
    Scene_MenuBase.prototype.initialize.call(this);
};

Scene_Casino.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    this.createCommandWindow();
    this.createDummyWindow();
    this.createGoldWindow();
    this.createPokaraWindow();
    this.createMatchesWindow();
};

Scene_Casino.prototype.createCommandWindow = function() {
    this._commandWindow = new Window_CasinoCommand(Graphics.boxWidth);
    this._commandWindow.setHandler('pokara', this.commandPokara.bind(this));
    this._commandWindow.setHandler('matches', this.commandMatches.bind(this));
    this._commandWindow.setHandler('cancel', this.popScene.bind(this));
    this.addWindow(this._commandWindow);
};

Scene_Casino.prototype.createDummyWindow = function() {
    var wy = this._commandWindow.y + this._commandWindow.height;
    var wh = Graphics.boxHeight - wy;
    this._dummyWindow = new Window_Base(0, wy, Graphics.boxWidth, wh);
    this.addWindow(this._dummyWindow);
};

Scene_Casino.prototype.createGoldWindow = function() {
    this._goldWindow = new Window_Gold(0, 0);
    this._goldWindow.y = Graphics.boxHeight - this._goldWindow.height;
    this.addWindow(this._goldWindow);
};

Scene_Casino.prototype.createMatchesWindow = function() {
    var wy = this._commandWindow.y + this._commandWindow.height;
    var wh = Graphics.boxHeight - wy;
    this._matchesWindow = new Window_CasinoMatches(0, wy, Graphics.boxWidth, wh);
    this._matchesWindow.hide();
    this._matchesWindow.setHandler('cancel', this.onMatchesCancel.bind(this));
    this.addWindow(this._matchesWindow);
};

Scene_Casino.prototype.createPokaraWindow = function() {
    var wy = this._commandWindow.y + this._commandWindow.height;
    var wh = Graphics.boxHeight - wy - this._goldWindow.height;
    this._pokaraWindow = new Window_CasinoPokara(0, wy, Graphics.boxWidth, wh, this);
    this._pokaraWindow.hide();
    this._pokaraWindow.setHandler('cancel', this.onPokaraCancel.bind(this));
    this.addWindow(this._pokaraWindow);
};

Scene_Casino.prototype.commandPokara = function() {
    this._dummyWindow.hide();
    this._matchesWindow.hide();
    this._goldWindow.show();
    this._goldWindow.refresh();
    this._pokaraWindow.show();
    this._pokaraWindow.refresh();
    this._pokaraWindow.activate();
};

Scene_Casino.prototype.commandMatches = function() {
    this._dummyWindow.hide();
    this._pokaraWindow.hide();
    this._goldWindow.hide();
    this._matchesWindow.show();
    this._matchesWindow.refresh();
    this._matchesWindow.activate();
};

Scene_Casino.prototype.onPokaraCancel = function() {
    this._pokaraWindow.deactivate();
    this._commandWindow.activate();
};

Scene_Casino.prototype.onMatchesCancel = function() {
    this._matchesWindow.deactivate();
    this._commandWindow.activate();
};
Constructor is supposed to be a string, isn't it? Just put "Scene_Casino" in quotation marks on that line.

Scene_Casino.prototype.constructor = "Scene_Casino";
No good. Still having problems.
Alright, I was wrong about setting it as a string. I looked at my own plugin in which I made a custom scene using Scene_MenuBase as the starting point, and the top several lines are basically the same as the ones you've posted.

JavaScript:
========================================================
Scene_Crafting
========================================================
*/

function Scene_Crafting() {
    this.initialize.apply(this, arguments);
}

Scene_Crafting.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Crafting.prototype.constructor = Scene_Crafting;

Scene_Crafting.prototype.initialize = function() {
//etc
The issue with the code giving you that error is not coming from those lines.
i once encounter something like that... but in my case it's because i put it inside:
Code:
(function($){

code here

})(EST.MyPluginName);

apparently this kind of code:
Code:
function Scene_PhoneAddonBase() {
    this.initialize.apply(this, arguments);
}
does not work well if put inside above coding style...
because it's recognized as creating a local function inside the function($){}(EST.MyPluginName) above and thus we cannot use Scene_PhoneAddonBase... i think this also apply to :
Code:
(function(){

code here

})();
type of coding style... or all other similar coding sytle... basically all wrapper style of coding (usually to make aliasing did not disturb other people plugin).

so to fix above... i change it to :
Code:
Scene_PhoneAddonBase = function() {
    this.initialize(...arguments);
};

maybe try that in your plugin to see does it work or not.

hope this help.
I figured it out. Turns out that the suit design wasn't implemented properly (the wrong lines were uncommented) so I changed the comment lines, created the required image files and everything's set. I also changed it from the author's rules so that it uses a standard deck and payout structure which fits my needs a lot better.

I also managed to fix some bugs and will be considering an upload of the latest version at some point in the future.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/problem-with-scene-constructors.129939/