MV Scene_PressStart is not defined

I need some help with something that troubles me which I dont really get why it is happing.

so let me tell you what DOES work.

Press Start is a plugin I made for my side project and works really nice.

as it has GameEnd and to title, the "SceneManager.goto(Scene_PressStart)" is working (but I rule it out)
as the game dont uses menu usages!

it also has a custom GameOver scene and also uses "SceneManger.goto(Scene_PressStart)" and that
works without an issue.

PressStart also instantly start the game without any problem.

What DOES NOT work, I repeat NOT WORK is the scriptcall SceneManager.goto(Scene_PressStart);
which is called from a common event when once the timer is out of time.

while the plugin isn't public, I post it here but it is NOT FOR USE IN ANY GAME! except my own game!
as it is made specially for it.

I just need to know why the scriptcall throws that error and run fine when gameOver, and what
modification I need to make in order to make it function correctly.


Spoiler: Press Start Code
JavaScript:
    function Scene_PressStart() {
        this.initialize.apply(this, arguments);
    };

    Scene_PressStart.prototype = Object.create(Scene_Base.prototype);
        Scene_PressStart.prototype.constructor = Scene_PressStart;

    Scene_PressStart.prototype.initialize = function() {
        Scene_Base.prototype.initialize.call(this);
    };

    Scene_PressStart.prototype.create = function() {
        Scene_Base.prototype.create.call(this);
            this.createPrSt_Background();
    };

    Scene_PressStart.prototype.createPrSt_Background = function() {
        this._PrStPic = new Sprite_Button();
        this._PrStBGPic = new Sprite_Button();
        this._PrStPic.bitmap = ImageManager.loadSystem("ShadowDragon_PrSt");
        this._PrStBGPic.bitmap = ImageManager.loadSystem("ShadowDragon_BG");
        this._PrStPic.x = ShadowDragon._PSposX;
        this._PrStPic.y = ShadowDragon._PSposY;
        this._PrStPic.setClickHandler(this.command_PrSt.bind(this));
        this.addChildAt(this._PrStBGPic, 0);
        this.addChildAt(this._PrStPic, 1);
    };

    Scene_PressStart.prototype.command_PrSt = function() {
        SoundManager.playOk();
        this.removeChild(this._PrStPic);
        this.removeChild(this._PrStBGPic);
        this.commandNewGame();
    };

    Scene_PressStart.prototype.update = function() {
        Scene_Base.prototype.update.call(this);
            this._PrStFrCount++;
            this._PrStFrCount %= 40;  // using Modulo to count the frames (fixed)
            this._PrStPic.opacity = (20 - this._PrStFrCount) * 25;

        if (Input.isTriggered('ok') || Input.isTriggered('cancel')){
            SoundManager.playOk();
            this.commandNewGame();
        };
    };

    Scene_PressStart.prototype.commandNewGame = function() {
        DataManager.setupNewGame();
        //this._commandWindow.close();
        //this.fadeOutAll();   // remove fade for instant transfer
        SceneManager.goto(Scene_Map);
    };

    Scene_PressStart.prototype.start = function() {
        Scene_Base.prototype.start.call(this);
            this.startFadeIn(this.slowFadeSpeed(), false);
            this._PrStFrCount = 25;  // Fixed number, DO NOT CHANGE
    };

The code for GameEnd (ruled out) and Game Over is irrelivant, but the code not working
is something between those lines which I dont get.

I remove the code once it is solved, but DO NOT USE MY CODE IN YOUR GAME, use a better
version for press start if you want one, like Galv_CustomTitle, Eli_PressStart or TSR_Title!
I legit did not know that SceneManager.goto() was a thing 😅
Though I have successfully used SceneManager.push() instead in common events. So try that maybe?
Does the error trace not provide a line number?
@eomereolsson push is more for other scenes, Scene_Title uses goto.

@ATT_Turan not specifically no, just the rpg_manager and other core files,
nothing related to plugin itself, which troubles me why like this error:

Untitled-2.png

if it throws the line number, than I could see why, but I have no clue why it is not defined.
Well, it's giving you a clue, isn't it?

It looks to me like it's saying that you're using the Script event command someplace, and inside of that you're referencing Scene_PressStart in a way that's not defined (e.g. as a variable instead of a function call or Object type).
but the problem is, e.stack and things that arent from the object.

I dont get why SceneManager.goto(Scene_PressStart) works find
in GameOver but not from scriptcall where Scene_Title works.

but checking Scene_Title to see what I'm missing to get is something
I dont see as most aren't relevant.

the object parts is things I dont get either why there, or I would seek
help what I'm missing to make it work as I though I got everything correctly
working except the scriptcall wont work, ommit it in a different way didnt work
out either.
Is your Scene_PressStart code inside an IIFE?
do you mean this one?

(() => { code })();

than yes, most of my plugins uses that, why?
I've had that with my own code too, calling the scene within an IIFE from a script call doesn't work. So I just wrote a plugin command within that IIFE that has SceneManager going to that scene.
I've had that with my own code too, calling the scene within an IIFE from a script call doesn't work. So I just wrote a plugin command within that IIFE that has SceneManager going to that scene.
that is not an bad idea, didn't though of that one as it seems it wasn't required,
but I can definitely try that one though.

I though more of a missing function, so I try that one as if it does work, it can
solve my problem that way.
do you mean this one?

(() => { code })();

than yes, most of my plugins uses that, why?
Well there you have your reason. With this you explicitly tell javascript that you don't want anything outside of the direct code of your plugin to know about it. When you then try to access this in an event command you will not be able to, as you have seen.
Why did you exclude that from the plugin code you posted?

EDIT: Using IIFEs makes a lot of people very angry and is widely regarded as a bad move 😉:
@eomereolsson that plugin was made in 2020, one of my first to learn
and start easy 🙂

but I didn't think the boot part and gameover are kind of relavant as it
isn't really public plugin as based on my side game.

but I keep that in mind when to use it and when not 🙂

@SeaPhoenix making a plugin command to target the scene does indeed
do the trick nicely, something that didn't come to mind on a simple press start
scene that works nicely.

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/scene_pressstart-is-not-defined.150587/