MOG_SceneMenu.js (center align ActorLevel & HP/MP bar "scroll-speed" change)

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
986
Reaction score
1,281
First Language
Swedish
Primarily Uses
RMMV
I'm using MogHunters "MOG_SceneMenu.js (it's part of his "Monogatari" plugin set, each handling their own scene). It's a cool plugin but I'm having some problems...

Basically, I want to display the actor's current level number center aligned, inside an orb, so that even when the number becomes 10+, it will still be centered within that orb and not look like it does in the image below.


As you can see, the numbers "4" and "7" looks fine but "13" and "10" is off-center because they consist of two numbers. I assume this happens because the actor's current level number is either aligned to the left or to the right.

I looked at the code myself but as per usual, I'm such a clueless bamboo bear. Can't really say I understand much. But I think this here is the code that relates to how the numbers for the actor's current level are drawn:

Code:
//==============================
// * create LV Number
//==============================
MCharStatus.prototype.createLVNumber = function() {
    this._lv_number = [];
    this._NumberData3 = [this._numberImg3.width / 10,this._numberImg3.height]
    var x = this._layout.x + Moghunter.scMenu_LVNumberX;
    var y = this._layout.y + Moghunter.scMenu_LVNumberY;
    for (var i = 0; i < 3; i++) {
         this._lv_number[i] = new Sprite(this._numberImg3);
         this._lv_number[i].visible = false;
         this._lv_number[i].opacity = 255;
         this._lv_number[i].x = x ;
         this._lv_number[i].y = y ;
         this.addChild(this._lv_number[i]);     
    };
    this.refresh_number(this._lv_number,this._actor.level,this._NumberData3,x)
};

//==============================
// * Refresh Number
//==============================
MCharStatus.prototype.refresh_number = function(sprites,value,img_data,x) {
    if (value > 99999) {value = 99999};
    numbers = Math.abs(value).toString().split("");
       for (var i = 0; i < sprites.length ; i++) {
       sprites[i].visible = false;
       if (i < numbers.length) {
           var n = Number(numbers[i]);
           sprites[i].setFrame(n * img_data[0], 0, img_data[0], img_data[1]);
           var nx = -(img_data[0] * i) + (img_data[0] *  numbers.length);
           sprites[i].x = x - nx;
           sprites[i].visible = true;
       } else {
          var n = 0;
          sprites[i].setFrame(n * img_data[0], 0, img_data[0], img_data[1]);
          var nx = -(img_data[0] * i) + (img_data[0] *  (sprites.length + numbers.length));
          sprites[i].x = x - nx;
       };
    };
};
This might be obvious for someone who knows javascript from reading the above snippet, but I'll mentioned it anyway. These numbers that are used to display the actors current level are not drawn with the gamefont. They're drawn from an image file you have to make yourself.

The one I'm using for my game is this one below:
LVNumber.png

-----------------------------------------------------

[EDIT; I've already found a solution to the below problem so the only thing I need help with is the above issue. (Thank you @minnty200) ]

And then there's one more problem, which is not as crucial, it's one that I can live with but eh... might as well ask and learn something.

In Moghunter's menu plugins the HP and MP gauges are animated. Or rather, they scroll horizontally in a looping manner. This looks pretty cool and I've decided to make use of this but... it scrolls waaay too fast. Just look at the image below and I think you see what I mean:

At least in my opinion it moves so fast I find it almost stresses me out, and I think it actually distracts the player more than it should. Therefore I'd like to slow down the movement of the HP an MP bar somehow, but as usual, there's no parameter for it so it would have to be done directly in the script - something that's a bit beyond my own knowledge.

So, uh... help... anyone? :kaocry:

I'm pretty clueless but again, I assume (don't trust me on this) that the relevant piece of code is inside this snippet below?

Code:
//==============================
// * create LV Number
//==============================
MCharStatus.prototype.createLVNumber = function() {
    this._lv_number = [];
    this._NumberData3 = [this._numberImg3.width / 10,this._numberImg3.height]
    var x = this._layout.x + Moghunter.scMenu_LVNumberX;
    var y = this._layout.y + Moghunter.scMenu_LVNumberY;
    for (var i = 0; i < 3; i++) {
         this._lv_number[i] = new Sprite(this._numberImg3);
         this._lv_number[i].visible = false;
         this._lv_number[i].opacity = 255;
         this._lv_number[i].x = x ;
         this._lv_number[i].y = y ;
         this.addChild(this._lv_number[i]);      
    };
    this.refresh_number(this._lv_number,this._actor.level,this._NumberData3,x)
};

//==============================
// * Refresh Number
//==============================
MCharStatus.prototype.refresh_number = function(sprites,value,img_data,x) {
    if (value > 99999) {value = 99999};
    numbers = Math.abs(value).toString().split("");
       for (var i = 0; i < sprites.length ; i++) {
       sprites[i].visible = false;
       if (i < numbers.length) {
           var n = Number(numbers[i]);
           sprites[i].setFrame(n * img_data[0], 0, img_data[0], img_data[1]);
           var nx = -(img_data[0] * i) + (img_data[0] *  numbers.length);
           sprites[i].x = x - nx;
           sprites[i].visible = true;
       } else {
          var n = 0;
          sprites[i].setFrame(n * img_data[0], 0, img_data[0], img_data[1]);
          var nx = -(img_data[0] * i) + (img_data[0] *  (sprites.length + numbers.length));
          sprites[i].x = x - nx;
       };
    };
};
Many thanks to anyone taking their time to read through all this.

[EDIT; Moghunters Monogatari plugins can be downloaded from here: https://atelierrgss.wordpress.com/rmv-monogatari/]
 
Last edited:

minnty200

Veteran
Veteran
Joined
May 2, 2020
Messages
52
Reaction score
18
First Language
eng
Primarily Uses
RMMV
Code:
//==============================
// * create LV Number
//==============================
MCharStatus.prototype.createLVNumber = function() {
    this._lv_number = [];
    this._NumberData3 = [this._numberImg3.width / 10,this._numberImg3.height]
   
       
        if( this._actor.level >= 10){
                var x = this._layout.x + Moghunter.scMenu_LVNumberX + 10;
        } else{
            var x = this._layout.x + Moghunter.scMenu_LVNumberX;

        };

    var y = this._layout.y + Moghunter.scMenu_LVNumberY;
    for (var i = 0; i < 3; i++) {
         this._lv_number[i] = new Sprite(this._numberImg3);
         this._lv_number[i].visible = false;
         this._lv_number[i].opacity = 255;
         this._lv_number[i].x = x ;
         this._lv_number[i].y = y ;
         this.addChild(this._lv_number[i]);        
    };  
    this.refresh_number(this._lv_number,this._actor.level,this._NumberData3,x)
};

Where line var x = this._layout.x + Moghunter.scMenu_LVNumberX + 10; is where it adjusts x cord of any level greater than 10 (two digit numbers). The purple number is the adjustment number. Purple number is something you need to do trail and error on to get it center with your own layout images.
Hope it works.

edit: Lol let me know if you also need it to support actors equal to or greater than 100
 

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
986
Reaction score
1,281
First Language
Swedish
Primarily Uses
RMMV
@minnty200
Thank you, but I'm afraid it's not a solution since it creates a new problem! :kaoswt:

It does fix the level number alignment for actors which are currently level 10+, but since the positioning also affects the numbers for level 1-9, putting "+ 10" (for example) in there means that the numbers for actors that are level 1-9 will be off-centered instead - while level 10-99 will be centered. It just kinda reversed the problem.

If it's possible, I think "center" alignment for the images displaying the numbers would work the best, since it should auto-adjust from it's anchor point. But I've no idea how to change that or how easy it would be, since there's nothing in the code that mentions alignment.

Is it not a thing for image files in JavaScript maybe? I find that hard to believe but I know more or less nothing.
 

minnty200

Veteran
Veteran
Joined
May 2, 2020
Messages
52
Reaction score
18
First Language
eng
Primarily Uses
RMMV
Hmm that's weird that it is changing the positioning for level 1-9! :( I tried it in my own game a few times and it seemed to work well. The code shouldn't make any change for levels 1-9, only for two digit numbers. Its not as simple as a "center" alignment i'm afraid because a "center" would need a range of coordinates to pick from in order to "center" it's self (Sorry... I'm bad at explaining... >.<) Here's a screen shot of it from my menu screen. Middle character's level has not moved, but the right and left character, that are two digits, have been pushed over by 100 pixels.
 
Last edited:

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
986
Reaction score
1,281
First Language
Swedish
Primarily Uses
RMMV
Hm, maybe I'm fiddling with the wrong part of the script then?

I've changed line "1271" to this:

var x = this._layout.x + Moghunter.scMenu_LVNumberX +10;

I don't think it' should matter but since I use my own graphics I've already changed the position of "LV Number" in the plugin parameters so it's not in it's original spot in my game.

 

minnty200

Veteran
Veteran
Joined
May 2, 2020
Messages
52
Reaction score
18
First Language
eng
Primarily Uses
RMMV
Did you copy and paste the whole code I provided? Sorry, I should have been more clear that the entirety of the code I provided needs to be replaced in the script. I added and created an If/else statement in that code which differs from the original plugin's script.
 

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
986
Reaction score
1,281
First Language
Swedish
Primarily Uses
RMMV
@minnty200
I didn't notice your added if/else statements, silly me.

Thank you, that did it! Now all character levels are displayed properly in the main menu. Hurrah! :kaojoy:
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I love the Time Fantasy tiles, but haven't played anything made with it yet. Can anyone recommend me something?
Vote for what I show more indepth on Twitter tomorrow from the MZ default resources
Oh look, 12 more free Daz3D models. *adds them to his collection * Yes, the fools... Give it a few months and my collection will be crazy, all without paying a dime. I still have no idea if I'll ever learn the software, but hey... Just in case, these models are quite expensive. In two weeks, they've already given me almost $400 worth of free models. :LZSexcite:
Not easy to find DS resources, is it? I need to make a good compilation thread linking to all the artists that do DS...
Spent a whole evening planning Stats, Animations, Abilities of 24 different weapons.. Only to realize I was just Bloating the Game. In the end i decided to stick with only 6.

Forum statistics

Threads
99,351
Messages
964,373
Members
130,949
Latest member
MasterLink009
Top