Support with "Level Up" Message

Hello RPG Makers!

Disclaimer: This is my first post, so any feedback is welcome. I have searched for this issue in the forums and haven't found a person with the same problem, so I'll be glad if someone can help me out with this:

Context:
A) My levels have names, they aren't numbers. For example:
Level 1 is "Novice"
Level 2 is "Knight"

B ) I have achieved that with the following Plug-In:
Spoiler
Code:
Window_StatusBase.prototype.drawActorLevel = function(actor, x, y) {
    let levelName = null;
    if(actor.level == 1){
      levelName = "Novice"
    }
    if(actor.level == 2){
      levelName = "Knight"

    this.drawText(levelName, x, y, 36, "right");
};

C) My Level Up Message in Terms is the following:
Code:
%1 is now %2: %3!



Issue/Problem:
The return message when I level up to Level 2 reads: "Actor is now Rank: 2"
And I want the message to read: "Actor is now Rank: Knight"

thanks in advance!
Hello and welcome! If you haven't already, please read through the Support Template, it will help others help you more effectively. In this case, what plugins you are using is relevant.

In any case, the code that you showed should throw an error (you're missing a closing curly for the second if clause). So if you say that the level up message hasn't changed (meaning that it didn't crash on load) my first suspicion is that the plugin hasn't been loaded at all.

EDIT: also, the code you showed is for the status window. So it won't affect how the level shows up in the level up message. To tweak the message, one way of doing it is to tweak the displayLevelUp function, for example:

JavaScript:
Game_Actor.prototype.displayLevelUp = function(newSkills) {
    const text = TextManager.levelUp.format(
        this._name,
        TextManager.level,
//Array with ranks, pick the index equal to numerical level minus one
        ['Novice','Knight'][this._level-1]
//Original code
//        this._level
        );
    $gameMessage.newPage();
    $gameMessage.add(text);
    for (const skill of newSkills) {
        $gameMessage.add(TextManager.obtainSkill.format(skill.name));
    }
};

It will work if you just add more ranks to the array like ['Novice','Squire','Knight','Hero'], but do note that it's probably better to make it read a class note tag.
Hello Canned_Dinosaur,
Thanks for the fast reply and clear answer. I'll definitely read the Support Post Template for future posts.

___

First of all, yes, you are right, the code I pasted on the post is missing a "{".
That was, in fact, an error of mine when posting this thread. Because the plug-in actually has much more ranks, it goes up to 10 ranks. But I didn't want to paste the whole code here, so I trimmed it for simplicity; and in the trimming I missed the "{". Nice catch.

The plug-in I'm using for this is actually a text given to me by a kind stranger in a Discord channel. I don't believe the plug-in has a name or something. I don't have any other plug-ins at the moment.
____

Secondly, thanks for the solution. I will try it out and report on the results. I hope this post helps people in the future with the same problem.
Hope it works! If you need a notetagged version (basically you list the level names in the notes in the class and the plugin will pick up the list from there), I can add that in and combine this one and the kind stranger plugin into a single plugin.

As with the code that I showed above, the kind stranger plugin can also be condensed as follows:

JavaScript:
Window_StatusBase.prototype.drawActorLevel = function(actor, x, y) {
    const levelName = ['Novice','Knight'][actor._level-1];
    this.drawText(levelName, x, y, 36, "right");
};

Original thread: https://forums.rpgmakerweb.com/threads/support-with-level-up-message.180280/