MZ Making a guagebar for a variable in JavaScript

I'm trying to make a gauge for a set variable. I think the normal gauges are hardcoded into rpg maker. Is there a way to replicate it to be used in a plugin? Using Visual Studio and the plugin I'm trying to make is for MZ specifically. This is my code currently:

JavaScript:
(function () {
    var params = PluginManager.parameters("PB_Sync_Mechanic")

    var number = params["Sync Level Minimum"];
    var number = params["Sync Level Maximum"];


    
})();

function Scene_Sync() {
    this.initialize();
}

Scene_Sync.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Sync.prototype.constructor = Scene_Sync;

Scene_Sync.prototype.initialize = function () {
    Scene_MenuBase.prototype.initialize.call(this);
};
//Creates First Window
Scene_Sync.prototype.create = function () {
    Scene_MenuBase.prototype.create.call(this);
    this._customWindow = new Window_Custom(0, 25, 320, 240);
    this.addWindow(this._customWindow);
}

//Update
Scene_Sync.prototype.update = function () {
    if (!this.drawnWindows) {
        this._customWindow.drawAllItems();
        this.drawnWindows = true;
    }


}

//Draws Window
function Window_Custom() {
    this.initialize.apply(this, arguments);
}

Window_Custom.prototype = Object.create(Window_Base.prototype);
Window_Custom.prototype.contructor = Window_Custom;

Window_Custom.prototype.initialize = function (x, y, width, height) {
    Window_Base.prototype.initialize.call(this, x, y, width, height);
    this.drawAllItems();

}
//Writes Text
Window_Custom.prototype.drawAllItems = function () {
    this.drawText($gameVariables.value(130), 0, 0, this.width - this.padding * 2, "center");
    this.drawFace("Telos", 5, 96, 48, 148, 148);

};
Can anyone help me?
We're not supposed to double post until it's been 72 hours - you didn't even wait 12 😉

Everyone here is a volunteer with a life, and your two posts were during the night for anyone in the USA.

Please be patient.

That being said, I don't see where in your code you're trying to draw a gauge. You can see the Sprite_Gauge definition and methods in rmmz_sprites.js, and you can look through rmmz_windows to see how it's used to create gauges in existing parts of the engine.

Can you clarify what you've tried that didn't work?
I saw the sprite gauge function in rmmz_sprites.js. Do I just take the entire function and put it in my plugin? Or can I call the function from my plugin? This is the block right?:


JavaScript:
function Sprite_Gauge() {
    this.initialize(...arguments);
}

Sprite_Gauge.prototype = Object.create(Sprite.prototype);
Sprite_Gauge.prototype.constructor = Sprite_Gauge;

Sprite_Gauge.prototype.initialize = function() {
    Sprite.prototype.initialize.call(this);
    this.initMembers();
    this.createBitmap();
};

Sprite_Gauge.prototype.initMembers = function() {
    this._battler = null;
    this._statusType = "";
    this._value = NaN;
    this._maxValue = NaN;
    this._targetValue = NaN;
    this._targetMaxValue = NaN;
    this._duration = 0;
    this._flashingCount = 0;
};

Sprite_Gauge.prototype.destroy = function(options) {
    this.bitmap.destroy();
    Sprite.prototype.destroy.call(this, options);
};

Sprite_Gauge.prototype.createBitmap = function() {
    const width = this.bitmapWidth();
    const height = this.bitmapHeight();
    this.bitmap = new Bitmap(width, height);
};

Sprite_Gauge.prototype.bitmapWidth = function() {
    return 128;
};

Sprite_Gauge.prototype.bitmapHeight = function() {
    return 32;
};

Sprite_Gauge.prototype.textHeight = function() {
    return 24;
};

Sprite_Gauge.prototype.gaugeHeight = function() {
    return 12;
};

Sprite_Gauge.prototype.gaugeX = function() {
    if (this._statusType === "time") {
        return 0;
    } else {
        return this.measureLabelWidth() + 6;
    }
};

Sprite_Gauge.prototype.labelY = function() {
    return 3;
};

Sprite_Gauge.prototype.labelFontFace = function() {
    return $gameSystem.mainFontFace();
};

Sprite_Gauge.prototype.labelFontSize = function() {
    return $gameSystem.mainFontSize() - 2;
};

Sprite_Gauge.prototype.valueFontFace = function() {
    return $gameSystem.numberFontFace();
};

Sprite_Gauge.prototype.valueFontSize = function() {
    return $gameSystem.mainFontSize() - 6;
};

Sprite_Gauge.prototype.setup = function(battler, statusType) {
    this._battler = battler;
    this._statusType = statusType;
    this._value = this.currentValue();
    this._maxValue = this.currentMaxValue();
    this.updateBitmap();
};

Sprite_Gauge.prototype.update = function() {
    Sprite.prototype.update.call(this);
    this.updateBitmap();
};

Sprite_Gauge.prototype.updateBitmap = function() {
    const value = this.currentValue();
    const maxValue = this.currentMaxValue();
    if (value !== this._targetValue || maxValue !== this._targetMaxValue) {
        this.updateTargetValue(value, maxValue);
    }
    this.updateGaugeAnimation();
    this.updateFlashing();
};

Sprite_Gauge.prototype.updateTargetValue = function(value, maxValue) {
    this._targetValue = value;
    this._targetMaxValue = maxValue;
    if (isNaN(this._value)) {
        this._value = value;
        this._maxValue = maxValue;
        this.redraw();
    } else {
        this._duration = this.smoothness();
    }
};

Sprite_Gauge.prototype.smoothness = function() {
    return this._statusType === "time" ? 5 : 20;
};

Sprite_Gauge.prototype.updateGaugeAnimation = function() {
    if (this._duration > 0) {
        const d = this._duration;
        this._value = (this._value * (d - 1) + this._targetValue) / d;
        this._maxValue = (this._maxValue * (d - 1) + this._targetMaxValue) / d;
        this._duration--;
        this.redraw();
    }
};

Sprite_Gauge.prototype.updateFlashing = function() {
    if (this._statusType === "time") {
        this._flashingCount++;
        if (this._battler.isInputting()) {
            if (this._flashingCount % 30 < 15) {
                this.setBlendColor(this.flashingColor1());
            } else {
                this.setBlendColor(this.flashingColor2());
            }
        } else {
            this.setBlendColor([0, 0, 0, 0]);
        }
    }
};

Sprite_Gauge.prototype.flashingColor1 = function() {
    return [255, 255, 255, 64];
};

Sprite_Gauge.prototype.flashingColor2 = function() {
    return [0, 0, 255, 48];
};

Sprite_Gauge.prototype.isValid = function() {
    if (this._battler) {
        if (this._statusType === "tp" && !this._battler.isPreserveTp()) {
            return $gameParty.inBattle();
        } else {
            return true;
        }
    }
    return false;
};

Sprite_Gauge.prototype.currentValue = function() {
    if (this._battler) {
        switch (this._statusType) {
            case "hp":
                return this._battler.hp;
            case "mp":
                return this._battler.mp;
            case "tp":
                return this._battler.tp;
            case "time":
                return this._battler.tpbChargeTime();
        }
    }
    return NaN;
};

Sprite_Gauge.prototype.currentMaxValue = function() {
    if (this._battler) {
        switch (this._statusType) {
            case "hp":
                return this._battler.mhp;
            case "mp":
                return this._battler.mmp;
            case "tp":
                return this._battler.maxTp();
            case "time":
                return 1;
        }
    }
    return NaN;
};

Sprite_Gauge.prototype.label = function() {
    switch (this._statusType) {
        case "hp":
            return TextManager.hpA;
        case "mp":
            return TextManager.mpA;
        case "tp":
            return TextManager.tpA;
        default:
            return "";
    }
};

Sprite_Gauge.prototype.gaugeBackColor = function() {
    return ColorManager.gaugeBackColor();
};

Sprite_Gauge.prototype.gaugeColor1 = function() {
    switch (this._statusType) {
        case "hp":
            return ColorManager.hpGaugeColor1();
        case "mp":
            return ColorManager.mpGaugeColor1();
        case "tp":
            return ColorManager.tpGaugeColor1();
        case "time":
            return ColorManager.ctGaugeColor1();
        default:
            return ColorManager.normalColor();
    }
};

Sprite_Gauge.prototype.gaugeColor2 = function() {
    switch (this._statusType) {
        case "hp":
            return ColorManager.hpGaugeColor2();
        case "mp":
            return ColorManager.mpGaugeColor2();
        case "tp":
            return ColorManager.tpGaugeColor2();
        case "time":
            return ColorManager.ctGaugeColor2();
        default:
            return ColorManager.normalColor();
    }
};

Sprite_Gauge.prototype.labelColor = function() {
    return ColorManager.systemColor();
};

Sprite_Gauge.prototype.labelOutlineColor = function() {
    return ColorManager.outlineColor();
};

Sprite_Gauge.prototype.labelOutlineWidth = function() {
    return 3;
};

Sprite_Gauge.prototype.valueColor = function() {
    switch (this._statusType) {
        case "hp":
            return ColorManager.hpColor(this._battler);
        case "mp":
            return ColorManager.mpColor(this._battler);
        case "tp":
            return ColorManager.tpColor(this._battler);
        default:
            return ColorManager.normalColor();
    }
};

Sprite_Gauge.prototype.valueOutlineColor = function() {
    return "rgba(0, 0, 0, 1)";
};

Sprite_Gauge.prototype.valueOutlineWidth = function() {
    return 2;
};

Sprite_Gauge.prototype.redraw = function() {
    this.bitmap.clear();
    const currentValue = this.currentValue();
    if (!isNaN(currentValue)) {
        this.drawGauge();
        if (this._statusType !== "time") {
            this.drawLabel();
            if (this.isValid()) {
                this.drawValue();
            }
        }
    }
};

Sprite_Gauge.prototype.drawGauge = function() {
    const gaugeX = this.gaugeX();
    const gaugeY = this.textHeight() - this.gaugeHeight();
    const gaugewidth = this.bitmapWidth() - gaugeX;
    const gaugeHeight = this.gaugeHeight();
    this.drawGaugeRect(gaugeX, gaugeY, gaugewidth, gaugeHeight);
};

Sprite_Gauge.prototype.drawGaugeRect = function(x, y, width, height) {
    const rate = this.gaugeRate();
    const fillW = Math.floor((width - 2) * rate);
    const fillH = height - 2;
    const color0 = this.gaugeBackColor();
    const color1 = this.gaugeColor1();
    const color2 = this.gaugeColor2();
    this.bitmap.fillRect(x, y, width, height, color0);
    this.bitmap.gradientFillRect(x + 1, y + 1, fillW, fillH, color1, color2);
};

Sprite_Gauge.prototype.gaugeRate = function() {
    if (this.isValid()) {
        const value = this._value;
        const maxValue = this._maxValue;
        return maxValue > 0 ? value / maxValue : 0;
    } else {
        return 0;
    }
};

Sprite_Gauge.prototype.drawLabel = function() {
    const label = this.label();
    const x = this.labelOutlineWidth() / 2;
    const y = this.labelY();
    const width = this.bitmapWidth();
    const height = this.textHeight();
    this.setupLabelFont();
    this.bitmap.paintOpacity = this.labelOpacity();
    this.bitmap.drawText(label, x, y, width, height, "left");
    this.bitmap.paintOpacity = 255;
};

Sprite_Gauge.prototype.setupLabelFont = function() {
    this.bitmap.fontFace = this.labelFontFace();
    this.bitmap.fontSize = this.labelFontSize();
    this.bitmap.textColor = this.labelColor();
    this.bitmap.outlineColor = this.labelOutlineColor();
    this.bitmap.outlineWidth = this.labelOutlineWidth();
};

Sprite_Gauge.prototype.measureLabelWidth = function() {
    this.setupLabelFont();
    const labels = [TextManager.hpA, TextManager.mpA, TextManager.tpA];
    const widths = labels.map(str => this.bitmap.measureTextWidth(str));
    return Math.ceil(Math.max(...widths));
};

Sprite_Gauge.prototype.labelOpacity = function() {
    return this.isValid() ? 255 : 160;
};

Sprite_Gauge.prototype.drawValue = function() {
    const currentValue = this.currentValue();
    const width = this.bitmapWidth();
    const height = this.textHeight();
    this.setupValueFont();
    this.bitmap.drawText(currentValue, 0, 0, width, height, "right");
};

Sprite_Gauge.prototype.setupValueFont = function() {
    this.bitmap.fontFace = this.valueFontFace();
    this.bitmap.fontSize = this.valueFontSize();
    this.bitmap.textColor = this.valueColor();
    this.bitmap.outlineColor = this.valueOutlineColor();
    this.bitmap.outlineWidth = this.valueOutlineWidth();
};
So I mean no offense, obviously I don't know what your prior knowledge or skillsets are. But it sounds like you might want to do some more general JavaScript tutorials before you try something as ambitious as writing your own plugin. (and creating scenes/windows can be a bit on the complex side)

What you copied into your post is a big chunk of the source code file - every line that says Sprite_Gauge.prototype... = function is, logically enough, a function. Many of them are called by each other internally, there's no reason you'd reference more than one or two.

That's why I suggested you look at how windows that already use gauges are written (the battle status window or the menu status window).

Do I just take the entire function and put it in my plugin?
No, there's no reason to do that. It's already in the rmmz_sprites file - why would you want to put the same thing into another file?

What it looks like you will need to do, from a cursory glance, is copy two of the functions because you need to make changes - the currentValue and currentMaxValue. Those will need to recognize whatever you're calling your gauge and be told how to calculate the current and max value.

Or can I call the function from my plugin?
Yes, that's the whole point. There's no difference between the files in the js folder and your plugin file. They can access each other's code unless you take specific measures to restrict access.

You may want to take a look at SRD's Ultra HUD Maker, it provides a UI that may allow you to make what you're trying to do without having to manipulate the code yourself.
Its been hard finding good tutorials to explain specifically what I want to do. I've was watching some of Poryg the RPG Maker, but the tutorial was for MV and a lot of the important bits he doesn't show he just explains. I'm avoiding adding extras plugins since my current project has over 30 currently. I've programmed in game maker and c++, JavaScript is just very foreign to me.

I'm currently looking at JavaScript tutorials on calling functions from other .js files, hopefully that helps?
Risking sounding like an , if you have already coded in C++, Javascript shouldn't be that different. I have worked with Java for 10+ years as well with C++, C#, VB5, VB6 and even some obscure very specific software developing languages. I however understand that Javascript seems weird at first glance....well at any glance, it has very weird behaviours that I haven't been able to figure it out...and coming from Java that's saying a lot (Java has a lot of weird stuff too). In any case, I would suggest that, assuming you have very solid knowledge of coding (coding, not knowing a coding language, those are completely different things), find a good Javascript reference guide that explains things in a way that you can understand, that's what I normally do when coding things for my projects, specially when they are in a coding language I haven't used or have barely used.

While I'm no expert in gauges for MZ, from what I can glance in the code from some windows, you only need to link the gauge to a certain variable, like how the gauges are linked to HP, MP, TP and Time. The problem with that is that you will need to add some code to Sprite_Gauge in order to handle that, because it's not there by default, I mean the linking the variable to the gauge part, currently is kind of hard coded for HP, MP, TP and Time (time being the Time Progress System Time).

Also, adding the code to Sprite_Gauge is not enough, you will need to add the call to the gauge from a scene or a window, gauges just doesn't simply show by creating them, you can create a gauge but you have to show it and also you need to make sure the variable is linked is updated.

I would suggest that you look at the vanilla code for MZ in Window_BattleStatus, it has a lot of calls for gauges there, and then look at Sprite_Gauge, I don't remember if scenes in particular create gauges, but maybe Scene_Menu might call, but I'm not too sure.
I've programmed in game maker and c++, JavaScript is just very foreign to me.
I only had C/C++ experience before looking at RPG Maker code and...honestly, JavaScript syntax is, like, 80%? 90%? identical to C++. I mean, if you don't get it, you don't get it, and that's cool. It just strikes me as odd 🙂

I'm currently looking at JavaScript tutorials on calling functions from other .js files, hopefully that helps?
I really don't understand what that means. JavaScript and C++ are identical in this regard - you just call a function. There's no such thing as caring that it's in a different file, that doesn't mean anything. If the files are included in your project, you can use them.

Did you look at the windows code I pointed out to you? It has lots of function calls to sprite stuff - you just type it.

Did you check out the plugin I recommended at all? It really seems like it would be worth your time if that helped you to construct the UI you want without needing to get into the code.
Ok, so. This is what I have so far in terms of code. I got the windows, and I got the variables showing up and looking ok. I just can't figure out drawing the guage. I looked at the code in the sprites .js but it really is just for Hp, MP, and TP. I really don't want to have to reverse engeneer that. Can any of you point me to a resource that show HOW to make a gauge for Rpg maker. I've seen ways to draw shapes in JavaScript but I'm not sure if it can cross over into this.

1670995941870.png

JavaScript:
// JavaScript source code
/*:
 * @target MZ
 * @author PixieBixxie
 * @plugindesc Sync Mechanic Visual
 */



function Scene_Sync() {
    this.initialize();
}

Scene_Sync.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Sync.prototype.constructor = Scene_Sync;

Scene_Sync.prototype.initialize = function () {
    Scene_MenuBase.prototype.initialize.call(this);
};

//Creates First Window
Scene_Sync.prototype.create = function () {
    Scene_MenuBase.prototype.create.call(this);
    this._customWindow = new Window_Custom(0, 0, 1000, 624);
    this.addWindow(this._customWindow);
   
}
    function Window_Custom() {
        this.initialize.apply(this, arguments);
    }

Window_Custom.prototype = Object.create(Window_Selectable.prototype);
Window_Custom.prototype.constructor = Window_Custom;






Window_Custom.prototype.initialize = function (x, y, width, height) {
    Window_Selectable.prototype.initialize.call(this, x, y, width, height);
    this.drawAllItems();
};

//Draws Info
Window_Custom.prototype.drawAllItems = function () {
    //Title
    this.drawText("Antonio Sync Levels", 0, 0, this.width - this.padding * 2, "left");
    //Antman Face
    this.drawFace("Telos", 0, 0, 48, 148, 148);
    //Chollie
    this.drawText("Level With Chollie", 150, 65, this.width - this.padding * 2, "left");
    this.drawText($gameVariables.value(131), 0, 65, this.width - this.padding * 2, "right");
    //Newton
    this.drawText("Level With Newton", 150, 90, this.width - this.padding * 2, "left");
    this.drawText($gameVariables.value(132), 0, 90, this.width - this.padding * 2, "right");
    //Newton
    this.drawText("Level With Quill", 150, 115, this.width - this.padding * 2, "left");
    this.drawText($gameVariables.value(133), 0, 115, this.width - this.padding * 2, "right");
};

function Sync_Gauge() {
    this.initialize(...arguments);
}

Sync_Gauge.prototype = Object.create(Sprite.prototype);
Sync_Gauge.prototype.constructor = Sync_Gauge;

Sync_Gauge.prototype.initialize = function () {
    Sprite.prototype.initialize.call(this);
    this.initMembers();
    this.createBitmap();
};

Sprite_Gauge.prototype.initMembers = function () {
    this._battler = null;
    this._value = NaN;
    this._maxValue = NaN;
};
Ok, so. This is what I have so far in terms of code. I got the windows, and I got the variables showing up and looking ok. I just can't figure out drawing the guage. I looked at the code in the sprites .js but it really is just for Hp, MP, and TP. I really don't want to have to reverse engeneer that. Can any of you point me to a resource that show HOW to make a gauge for Rpg maker. I've seen ways to draw shapes in JavaScript but I'm not sure if it can cross over into this.

View attachment 247982
JavaScript:
// JavaScript source code
/*:
 * @target MZ
 * @author PixieBixxie
 * @plugindesc Sync Mechanic Visual
 */



function Scene_Sync() {
    this.initialize();
}

Scene_Sync.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Sync.prototype.constructor = Scene_Sync;

Scene_Sync.prototype.initialize = function () {
    Scene_MenuBase.prototype.initialize.call(this);
};

//Creates First Window
Scene_Sync.prototype.create = function () {
    Scene_MenuBase.prototype.create.call(this);
    this._customWindow = new Window_Custom(0, 0, 1000, 624);
    this.addWindow(this._customWindow);
 
}
    function Window_Custom() {
        this.initialize.apply(this, arguments);
    }

Window_Custom.prototype = Object.create(Window_Selectable.prototype);
Window_Custom.prototype.constructor = Window_Custom;






Window_Custom.prototype.initialize = function (x, y, width, height) {
    Window_Selectable.prototype.initialize.call(this, x, y, width, height);
    this.drawAllItems();
};

//Draws Info
Window_Custom.prototype.drawAllItems = function () {
    //Title
    this.drawText("Antonio Sync Levels", 0, 0, this.width - this.padding * 2, "left");
    //Antman Face
    this.drawFace("Telos", 0, 0, 48, 148, 148);
    //Chollie
    this.drawText("Level With Chollie", 150, 65, this.width - this.padding * 2, "left");
    this.drawText($gameVariables.value(131), 0, 65, this.width - this.padding * 2, "right");
    //Newton
    this.drawText("Level With Newton", 150, 90, this.width - this.padding * 2, "left");
    this.drawText($gameVariables.value(132), 0, 90, this.width - this.padding * 2, "right");
    //Newton
    this.drawText("Level With Quill", 150, 115, this.width - this.padding * 2, "left");
    this.drawText($gameVariables.value(133), 0, 115, this.width - this.padding * 2, "right");
};

function Sync_Gauge() {
    this.initialize(...arguments);
}

Sync_Gauge.prototype = Object.create(Sprite.prototype);
Sync_Gauge.prototype.constructor = Sync_Gauge;

Sync_Gauge.prototype.initialize = function () {
    Sprite.prototype.initialize.call(this);
    this.initMembers();
    this.createBitmap();
};

Sprite_Gauge.prototype.initMembers = function () {
    this._battler = null;
    this._value = NaN;
    this._maxValue = NaN;
};
Sprite_Gauge's setup functions provide branching code for HP, MP and TP. You need to add a fourth branch for the kind of resource you want the new gauge to track.
Sprite_Gauge's setup functions provide branching code for HP, MP and TP. You need to add a fourth branch for the kind of resource you want the new gauge to track.
In the actual rmmz_sprites.js? Or do I just bring the block over to my .js and add it there?
This is far as I got, I thought I defined everything, but now its in a constant loop. I'm going to bed cuz I'm stuck with the flu(got the shivers) but any help would def be appreciated.

JavaScript:
// JavaScript source code
/*:
 * @target MZ
 * @author PixieBixxie
 * @plugindesc Sync Mechanic Visual
 */



function Scene_Sync() {
    this.initialize();
}

Scene_Sync.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Sync.prototype.constructor = Scene_Sync;

Scene_Sync.prototype.initialize = function () {
    Scene_MenuBase.prototype.initialize.call(this);
};

//Creates First Window
Scene_Sync.prototype.create = function () {
    Scene_MenuBase.prototype.create.call(this);
    this._customWindow = new Window_Custom(0, 0, 1000, 624);
    this.addWindow(this._customWindow);
    
}
    function Window_Custom() {
        this.initialize.apply(this, arguments);
    }

Window_Custom.prototype = Object.create(Window_Selectable.prototype);
Window_Custom.prototype.constructor = Window_Custom;






Window_Custom.prototype.initialize = function (x, y, width, height) {
    Window_Selectable.prototype.initialize.call(this, x, y, width, height);
    this.drawAllItems();
};

Window_Custom.prototype.initialize = function (x, y, width, sync, color1, color2) {
    Window_Base.prototype.initialize.call(this, x, y, width, sync, color1, color2);
    this.drawGauge();
};

//Gauge Info
Window_Custom.prototype.drawGauge = function () {
    var x = 0, y = 0;                     // top-left gauge area coordinates
    var width = 100;                      // gauge width (px)
    var sync = $gameVariables.value(131);  // current gauge value (game var 1)
    var max = 10;                         // max value
    var rate = (sync / max).clamp(0, 1);
    var color1 = "#F0F8FF", color2 = "#A52A2A";  // fill styles
    this.drawGauge(x, y, width, sync, color1, color2);
};

//Draws Info
Window_Custom.prototype.drawAllItems = function () {
    //Title
    this.drawText("Antonio Sync Levels", 0, 0, this.width - this.padding * 2, "left");
    //Antman Face
    this.drawFace("Telos", 0, 0, 48, 148, 148);
    //Chollie
    this.drawText("Level With Chollie", 150, 65, this.width - this.padding * 2, "left");
    this.drawText($gameVariables.value(131), 0, 65, this.width - this.padding * 2, "right");
    //Newton
    this.drawText("Level With Newton", 150, 90, this.width - this.padding * 2, "left");
    this.drawText($gameVariables.value(132), 0, 90, this.width - this.padding * 2, "right");
    //Newton
    this.drawText("Level With Quill", 150, 115, this.width - this.padding * 2, "left");
    this.drawText($gameVariables.value(133), 0, 115, this.width - this.padding * 2, "right");
    this.drawGauge(150, 85, 100, $gameVariables.value(131), "#F0F8FF", "#A52A2A");
};



1671007274403.png
It's exceeding the maximum call stack because your rewritten drawGauge function is calling itself.

Yeah, take the functions from rmmz_sprites, paste them into your plugin, and add your additional value to them the same way as the core code does for HP, MP and TP currently.
In the actual rmmz_sprites.js? Or do I just bring the block over to my .js and add it there?
I told you in post #5 that you would need to copy the currentValue() and currentMaxValue() functions into your plugin and modify them to add your own value. And I didn't look exhaustively...you need to follow the path of the code and if there's anyplace else that references "hp" "mp" "tp" "time" you'll need to add yours there, also.

You should never modify the code in the default engine files, that's the whole point of you writing a plugin.

Can any of you point me to a resource that show HOW to make a gauge for Rpg maker.
There are lots of things that don't have any resources/tutorials when it comes to coding for RPG Maker. The basic goal of the software is to be usable by people who don't want to learn how to code, so most tutorials are explaining how to do things within the editor.

Once you get into coding for it with JavaScript, it's presumed that you know how to do that, so you're capable of reading the existing code, seeing how it works, and modifying or adding to it as necessary.

If you find you're not yet at that point, there are lots of generic JavaScript tutorials and classes available. Trihan has a Jump Into JavaScript series linked in his signature, but
A - it also presumes you have some fluency in JavaScript to begin with, and
B - it was based on MV, so unless he's changed it, this portion of the code was changed (and made a bit more complex) in MZ
I told you in post #5 that you would need to copy the currentValue() and currentMaxValue() functions into your plugin and modify them to add your own value. And I didn't look exhaustively...you need to follow the path of the code and if there's anyplace else that references "hp" "mp" "tp" "time" you'll need to add yours there, also.

You should never modify the code in the default engine files, that's the whole point of you writing a plugin.


There are lots of things that don't have any resources/tutorials when it comes to coding for RPG Maker. The basic goal of the software is to be usable by people who don't want to learn how to code, so most tutorials are explaining how to do things within the editor.

Once you get into coding for it with JavaScript, it's presumed that you know how to do that, so you're capable of reading the existing code, seeing how it works, and modifying or adding to it as necessary.

If you find you're not yet at that point, there are lots of generic JavaScript tutorials and classes available. Trihan has a Jump Into JavaScript series linked in his signature, but
A - it also presumes you have some fluency in JavaScript to begin with, and
B - it was based on MV, so unless he's changed it, this portion of the code was changed (and made a bit more complex) in MZ
Honestly Jump into Javascript goes fairly nicely over to MZ. The main difference is how windows work since they require a rect object in their constructor now.
Honestly Jump into Javascript goes fairly nicely over to MZ. The main difference is how windows work since they require a rect object in their constructor now.
Well I was referring specifically to this - in MV, you could fairly simply call drawGauge().

That's no longer the case in MZ with it referring to member variables to determine how far to fill it, and those variables being tied to specific predetermined parameters.
Well I was referring specifically to this - in MV, you could fairly simply call drawGauge().

That's no longer the case in MZ with it referring to member variables to determine how far to fill it, and those variables being tied to specific predetermined parameters.
That is true actually, they did make some fairly significant changes to how inner sprites are handled.
I told you in post #5 that you would need to copy the currentValue() and currentMaxValue() functions into your plugin and modify them to add your own value. And I didn't look exhaustively...you need to follow the path of the code and if there's anyplace else that references "hp" "mp" "tp" "time" you'll need to add yours there, also.

You should never modify the code in the default engine files, that's the whole point of you writing a plugin.


There are lots of things that don't have any resources/tutorials when it comes to coding for RPG Maker. The basic goal of the software is to be usable by people who don't want to learn how to code, so most tutorials are explaining how to do things within the editor.

Once you get into coding for it with JavaScript, it's presumed that you know how to do that, so you're capable of reading the existing code, seeing how it works, and modifying or adding to it as necessary.

If you find you're not yet at that point, there are lots of generic JavaScript tutorials and classes available. Trihan has a Jump Into JavaScript series linked in his signature, but
A - it also presumes you have some fluency in JavaScript to begin with, and
B - it was based on MV, so unless he's changed it, this portion of the code was changed (and made a bit more complex) in MZ
I'm going to do what you said. I just don't want to bail on this project since I've done everything BUT the variable gauges. Give me a few hours to try this out. I sincerely appreciate ALL the help you guys have been giving me.

Original thread: https://forums.rpgmakerweb.com/threads/making-a-guagebar-for-a-variable-in-javascript.153278/