Displaying parameters in multiple columns

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:

Spoiler
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;
        }
      
    };
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');
I will try this, thanks!

Original thread: https://forums.rpgmakerweb.com/threads/displaying-parameters-in-multiple-columns.117479/