Basic scripting question about getting a message to popup.

FatalErrorDriveB

Villager
Member
Joined
Dec 12, 2019
Messages
16
Reaction score
1
First Language
English
Primarily Uses
RMMV
So I'm trying to pop up a message warning the user if the plugin isn't set up properly.

Here's my code for that part. I'm sure I've made some very basic mistake but I'm new to Javascript and MV scripting so please go easy on me.
// Check to make sure name, attack, and effect are all equal values
if (numCards != numAtks || numCards != numEffects)
{
Game_Message.add("Warning! Your Monster Fighter plugin has not been set up properly!\nError: Uneven");
console.log("UNEVEN!!!");
}
I initially tried "$gameMessage.add();" but that pulled an error as well.

Any advise would be greatly appreciated.
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
698
Reaction score
3,450
First Language
English
Primarily Uses
N/A
What is the error you're getting? Because if the instance you're planning for would cause the program to crash, you won't get to run a game message call.

In a situation like this, use a try-catch architecture.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch

If you wrap the process you're running in the try braces, you can catch any errors, and handle them in the catch portion without crashing your game.

Check that link to learn more. Basically this gives you a chance to handle an error manually, and you can still do things like print out the error message without crashing first.
EDIT:
Also, you can't call Game_Message directly like that, it's a class that's already been instantiated to $gameMessage object. You just use $gameMessage.add, for the bare minimum of using a text box.
 

Soulrender

Jack Of All Trades
Veteran
Joined
Jan 12, 2019
Messages
839
Reaction score
467
First Language
Poland
Primarily Uses
RMMV
Call like this:
Code:
    $gameMessage.newPage();
    $gameMessage.setFaceImage(actorFaceFile, faceIndex);
    $gameMessage.setBackground(type); // 0, 1 or 2
    $gameMessage.setPositionType(pos); //0, 1 or 2
    $gameMessage.add("Your text... Why do I even bother... There are plenty more interesting things to do...");
 

FatalErrorDriveB

Villager
Member
Joined
Dec 12, 2019
Messages
16
Reaction score
1
First Language
English
Primarily Uses
RMMV
Call like this:
Code:
    $gameMessage.newPage();
    $gameMessage.setFaceImage(actorFaceFile, faceIndex);
    $gameMessage.setBackground(type); // 0, 1 or 2
    $gameMessage.setPositionType(pos); //0, 1 or 2
    $gameMessage.add("Your text... Why do I even bother... There are plenty more interesting things to do...");
Thank you!

What is the error you're getting? Because if the instance you're planning for would cause the program to crash, you won't get to run a game message call.

In a situation like this, use a try-catch architecture.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch

If you wrap the process you're running in the try braces, you can catch any errors, and handle them in the catch portion without crashing your game.

Check that link to learn more. Basically this gives you a chance to handle an error manually, and you can still do things like print out the error message without crashing first.
EDIT:
Also, you can't call Game_Message directly like that, it's a class that's already been instantiated to $gameMessage object. You just use $gameMessage.add, for the bare minimum of using a text box.
The instance doesn't crash the game, but it may cause big errors: in the script events, overtime, so I want to warn anyone who may use the script if it's configured incorrectly.
 

FatalErrorDriveB

Villager
Member
Joined
Dec 12, 2019
Messages
16
Reaction score
1
First Language
English
Primarily Uses
RMMV
Darn it, I double posted again, I'm sorry, I'll get it right soon.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top