MV Drawing Gauge by Script Call

Hello. I'm trying to draw a gauge bar with the intent of tracking a variable number.
I'd like the gauge to represent 0-10 value of a given variable.

Tried with the


Window_Base.prototype.drawGauge = function(300, 500, 10, 100, 50, #F0F8FF, #A52A2A, false)

But it doesn't work. Any idea?

What you've written will error out (bad syntax) but is closer to defining a new function than calling an existing one.

This blits a gauge to the message window on the map scene:
JavaScript:
var w = SceneManager._scene._messageWindow;
var x = 0, y = 0;                     // top-left gauge area coordinates
var width = 100;                      // gauge width (px)
var value = $gameVariables.value(1);  // current gauge value (game var 1)
var max = 10;                         // max value
var rate = (value / max).clamp(0, 1);
var color1 = "#F0F8FF", color2 = "#A52A2A";  // fill styles
w.drawGauge(x, y, width, rate, color1, color2);
I'd generally only recommend using drawGauge in a plugin, because any refresh of the target window's contents will also erase the gauge.
Thank you very much
What you've written will error out (bad syntax) but is closer to defining a new function than calling an existing one.

This blits a gauge to the message window on the map scene:
JavaScript:
var w = SceneManager._scene._messageWindow;
var x = 0, y = 0;                     // top-left gauge area coordinates
var width = 100;                      // gauge width (px)
var value = $gameVariables.value(1);  // current gauge value (game var 1)
var max = 10;                         // max value
var rate = (value / max).clamp(0, 1);
var color1 = "#F0F8FF", color2 = "#A52A2A";  // fill styles
w.drawGauge(x, y, width, rate, color1, color2);
I'd generally only recommend using drawGauge in a plugin, because any refresh of the target window's contents will also erase the gauge.
How would you call this in a plugin tho?
@PixelBoy360 - by patching an appropriate method on an appropriate object. If you don't understand what that means (and you want to learn) then I suggest reading the document in this thread:
It leads you through the basics of RMMZ plugin creation [edit: MV is mostly the same], with some beginner JavaScript stuff along the way. 👋

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/drawing-gauge-by-script-call.149480/