Status
Not open for further replies.

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,288
Reaction score
2,461
First Language
Dutch
Primarily Uses
RMMV
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.


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!
 

eomereolsson

Veteran
Veteran
Joined
Sep 29, 2021
Messages
433
Reaction score
358
First Language
German
Primarily Uses
RMMV
I legit did not know that SceneManager.goto() was a thing :rswt
Though I have successfully used SceneManager.push() instead in common events. So try that maybe?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,459
Reaction score
3,535
First Language
English
Primarily Uses
RMMV
Does the error trace not provide a line number?
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,288
Reaction score
2,461
First Language
Dutch
Primarily Uses
RMMV
@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.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,459
Reaction score
3,535
First Language
English
Primarily Uses
RMMV
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).
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,288
Reaction score
2,461
First Language
Dutch
Primarily Uses
RMMV
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.
 

SeaPhoenix

Veteran
Veteran
Joined
May 14, 2015
Messages
370
Reaction score
481
First Language
English
Primarily Uses
RMMV
Is your Scene_PressStart code inside an IIFE?
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,288
Reaction score
2,461
First Language
Dutch
Primarily Uses
RMMV
do you mean this one?

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

than yes, most of my plugins uses that, why?
 

SeaPhoenix

Veteran
Veteran
Joined
May 14, 2015
Messages
370
Reaction score
481
First Language
English
Primarily Uses
RMMV
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.
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,288
Reaction score
2,461
First Language
Dutch
Primarily Uses
RMMV
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.
 

eomereolsson

Veteran
Veteran
Joined
Sep 29, 2021
Messages
433
Reaction score
358
First Language
German
Primarily Uses
RMMV
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 :rwink::
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,288
Reaction score
2,461
First Language
Dutch
Primarily Uses
RMMV
@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.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,943
Reaction score
6,304
First Language
Dutch
Primarily Uses
RMXP

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.

 
Status
Not open for further replies.

Latest Profile Posts

There was a tutorial on how to draw anime eyes. Just draw Among Us. So I tried.
Screenshot_107.jpg
DamageActor3_7.png added!
index.php

Making a "characters first appearance" drawing for my game. Now I just have to finish the sprite art animation for her grand entrance.​
ScreenShot_9_24_2022_7_56_24.png
New area being started today. It leads to one of the games 2 optional bosses.
A secret desire of mine: I want to make a horror game based on Celtic mythology. I've seen plenty of Greek, Japanese and Norse mythology-based horror games, but I don't think I've ever seen a Celtic-based horror game anywhere...

Forum statistics

Threads
125,537
Messages
1,171,795
Members
164,607
Latest member
DemiDevil
Top