Displaying parameters in multiple columns

Creative Ed

Veteran
Veteran
Joined
Sep 16, 2013
Messages
301
Reaction score
316
First Language
Portuguese
Primarily Uses
RMMV
Hello, I'm currently modifying an existing plugin that creates a monster book, and in it I want to display the elements of the enemies in three columns. The plugin currently displays all the elements in one column only.

Here's the part I want to modify:

Code:
Window_MonsterInfo.prototype.drawResistancesTopPanel = function(rect)
    {
        var enemy = $dataEnemies[this._enemyId];

        this.makeFontBigger();
        this.drawText(resistancesText, rect.x-80, rect.y, rect.width);
        this.makeFontSmaller();

        var resArray = [];

        for (var i = 0; i < enemy.traits.length; i++)
        {
            if (enemy.traits[i].code === 11)
                resArray[enemy.traits[i].dataId] = enemy.traits[i].value;
        }

        var list = elementList.split(" ");
        var x = rect.x -40;
        var h = rect.y+25;
        var w = rect.width;

        for (var i = 1; i < $dataSystem.elements.length; i++)
        {
            if (elementMode == "HIDE" && list.contains(String(i))) continue;
            if (elementMode == "SHOW" && !list.contains(String(i))) continue;

            this.changeTextColor(this.systemColor());
            this.drawText($dataSystem.elements[i], x-40, h, w, 'left');
            this.resetTextColor();
            if (resArray[i])
            {
                var r = (resArray[i]*100).toFixed(0);
                if (r > 100)
                    this.changeTextColor(this.crisisColor());
                else if (r < 100)
                    this.changeTextColor(this.powerUpColor());

                this.drawText(r + "%", x-100, h, w, 'right');
            }
            else
                this.drawText("100%", x-100, h, w, 'right');
            h += this.lineHeight()-5.5;
        }
      
    };
 
Last edited:

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
965
Reaction score
708
First Language
English
Primarily Uses
RMMV
Looks as though you will need to divide the current index of elements by nine, the number of how many elements fit vertically into that sub-section of the screen. Then perhaps add around a hundred? Probably need to tweak that number. Then add that to the 'x' value.

Code:
var baseX = x + (Math.floor(i / 9) * 100);
// Math.floor(3 / 9) = 0 * 100 = 0 added to x
// Math.floor(12 / 9) = 1 * 100 = 100 added to x
// Math.floor(21 / 9) = 2 * 100 = 200 added to x
// And so on ...

this.drawText($dataSystem.elements[i], baseX - 40, h, w, 'left');
 

Creative Ed

Veteran
Veteran
Joined
Sep 16, 2013
Messages
301
Reaction score
316
First Language
Portuguese
Primarily Uses
RMMV
I will try this, thanks!
 

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

Latest Threads

Latest Profile Posts

What can I sing for my sisters birthday...?

>.<'
Well, I'll have you know that I'm still around, looking for opportunity to resurface with some stuffs.
I like to think of Profile Posts as tiny homes, full of all kinds of unsuspecting suckers "future" friends.... Many of which are of course only going to be excited when a strange man in black suddenly shows up to say hi. :LZSexcite:
Stream will be live shortly with some more Haunting Ground! Today, we encounter a new stalker! Feel free to drop by!
Tried the new Samsung Galaxy S20 Plus today. Very nice device overall, but flagship smartphone prices are getting completely out of control.

Forum statistics

Threads
94,499
Messages
921,450
Members
124,357
Latest member
ianhendrawan
Top