JavaScript questions that don't deserve their own thread

Is there a way to check the user base param in MZ?

user.agi gives me the total agi. I just want the base wo equip or buff value.

Thanks
JavaScript:
Game_Actor.prototype.paramBase = function(paramId) {
    return this.currentClass().params[paramId][this._level];
};

This is how the base script does it. So if you just want to find the current base, I think it would be user.paramBase(paramId). Use the id for the param you want to find, obviously. agi is 6, I believe.
Is there a way to refresh the battle status window? I'm trying to change its height based on the number of current party members, but it doesn't refresh mid-battle when I change the value returned by Window_BattleStatus.prototype.numVisibleRows.
For sprites created like below, how do I update the image later after?

this._face = new Sprite(ImageManager.loadBHud("Face_" + this._battler._actorId));
For sprites created like below, how do I update the image later after?

this._face = new Sprite(ImageManager.loadBHud("Face_" + this._battler._actorId));
Try using this command instead: $gameActors.actor(actorId).setFaceImage("faceName", faceIndex)
This will do the command you mentioned but apply the change correctly, it's the equivalent of the event command. What you entered doesn't set the index.
Replace actorId by the actor's database ID, faceName with the file name of the faceset, and faceIndex by the index of the face you want to use, starting from 0 and in reading order.
Example: $gameActors.actor(1).setFaceImage("Actor1", 0)
While I'm looking for something different, that's actually helpful to know as well, CHKNRAVE. ☺️

I'm looking for a solution for updating sprites that are drawn in menus in general, maybe through:

this.drawPicturename('PicName', 0, 0);

Window_Name.prototype.drawPicturename = function(filename, x, y) {
var bitmap = ImageManager.loadPicture(filename);
this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x, y);
};

Is something like Update and Refresh needed? How does that look like?
Where's the part of the MV engine that hard-codes the base stat of Luck to have a minimum of (positive) 1, and can I change the stat's minimum to negative 99 (or negative 999) without causing issues?
Is it better to buy the full version Alpha ABS plugin by Pheonix KageDesu or to subscribe to his Patreon and get it there?
While I'm looking for something different, that's actually helpful to know as well, CHKNRAVE. ☺️

I'm looking for a solution for updating sprites that are drawn in menus in general, maybe through:

this.drawPicturename('PicName', 0, 0);

Window_Name.prototype.drawPicturename = function(filename, x, y) {
var bitmap = ImageManager.loadPicture(filename);
this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x, y);
};

Is something like Update and Refresh needed? How does that look like?

Sprites are usually updated via the MyWindow.updateCursor() function.
Let me know if that helped

Where's the part of the MV engine that hard-codes the base stat of Luck to have a minimum of (positive) 1, and can I change the stat's minimum to negative 99 (or negative 999) without causing issues?

Check out the data folder of your project and open Classes.json file. You can manually change every parameter of every class to whatever you desire. The params array stores every stat of every param for every level. So it's gonna be a loong list. The luck stat is in param[7], so the 8th array within the param array.

For better understanding, this is the function that accesses the param base of every stat:

JavaScript:
//note that for luck stat the paramId is 7
Game_Actor.prototype.paramBase = function (paramId) {
    return this.currentClass().params[paramId][this._level];
};
I probably misused the "update" term.

How do I reflect changes to a window's sprite if, for example, a variable changes from 1 to 2 which determines which .png graphic to display:

if ($gameVariables.value(1) == 1) {
this.drawPicturename('PicNameA', 0, 0);
}

if ($gameVariables.value(1) >= 2) {
this.drawPicturename('PicNameB', 0, 0);
}

Window_Name.prototype.drawPicturename = function(filename, x, y) {
var bitmap = ImageManager.loadPicture(filename);
this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x, y);
};

==============

I hope to update sprites depending on certain changes in battle even to like (this is an example):
if 2 enemies, draw picture of sun
if 1 enemy left after defeating other one, update the sun to picture of moon
Seems like when I draw the initial picture based on condition, it doesn't change once it meets another criteria.


Thanks
I probably misused the "update" term.

How do I reflect changes to a window's sprite if, for example, a variable changes from 1 to 2 which determines which .png graphic to display:

if ($gameVariables.value(1) == 1) {
this.drawPicturename('PicNameA', 0, 0);
}

if ($gameVariables.value(1) >= 2) {
this.drawPicturename('PicNameB', 0, 0);
}

Window_Name.prototype.drawPicturename = function(filename, x, y) {
var bitmap = ImageManager.loadPicture(filename);
this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x, y);
};

==============

I hope to update sprites depending on certain changes in battle even to like (this is an example):
if 2 enemies, draw picture of sun
if 1 enemy left after defeating other one, update the sun to picture of moon
Seems like when I draw the initial picture based on condition, it doesn't change once it meets another criteria.


Thanks
With the contents canvas on windows the sprites "bleed" onto the canvas so to speak. So 10 sprites in a window become one big canvas that is static. Meaning, you have to clear the contents before drawing a new picture.

So try this first:
JavaScript:
if ($gameVariables.value(1) == 1) {
this.contents.clear();
this.drawPicturename('PicNameA', 0, 0);
}

However, there is another way to mess with sprites and have more control over them.

JavaScript:
Window_Name.prototype.drawPicturename = function(filename, x, y)    {
    //create a sprite to house the bitmap
    let spr = new Sprite();   
    let bitmap = ImageManager.loadPicture(filename);
    spr.bitmap = bitmap;
    //I'm sure there is a spr.position.set function or something like that
    //for easiert coding
    //note that x and y are anchored at the window's corner, not the screen's
    spr.x = x;
    spr.y = y;
    //add the sprite to a new window property named after the file
    this["_" + filename] = spr;
    //add it as a child otherwise you won't see it
    this.addChild(spr);
};

This way you have more control over the sprites. You can actively move them around, set opacity etc.

You can then access the sprite like this:
Window_Name._filename

I suggest you create both images in the beginning and set only one to visible and then switch visibility as necessary to show either moon or sun. Let me know if this helped.
I have been trying for a while with no avail and was wondering if there was a way to change a actors Max hp either by using the mhp variable or another way
@rexie09 I don't think you need a script. There's an event tab 1: Actor > Change Parameter > MaxHP.
@rexie09 I don't think you need a script. There's an event tab 1: Actor > Change Parameter > MaxHP.
Thank you for the answer i was not aware of that but i needed a way to add max hp in a script. You telling me about allowed me to find the function addParam that will do what i was looking for.
With the contents canvas on windows the sprites "bleed" onto the canvas so to speak. So 10 sprites in a window become one big canvas that is static. Meaning, you have to clear the contents before drawing a new picture.

So try this first:
JavaScript:
if ($gameVariables.value(1) == 1) {
this.contents.clear();
this.drawPicturename('PicNameA', 0, 0);
}

However, there is another way to mess with sprites and have more control over them.

JavaScript:
Window_Name.prototype.drawPicturename = function(filename, x, y)    {
    //create a sprite to house the bitmap
    let spr = new Sprite();  
    let bitmap = ImageManager.loadPicture(filename);
    spr.bitmap = bitmap;
    //I'm sure there is a spr.position.set function or something like that
    //for easiert coding
    //note that x and y are anchored at the window's corner, not the screen's
    spr.x = x;
    spr.y = y;
    //add the sprite to a new window property named after the file
    this["_" + filename] = spr;
    //add it as a child otherwise you won't see it
    this.addChild(spr);
};

This way you have more control over the sprites. You can actively move them around, set opacity etc.

You can then access the sprite like this:
Window_Name._filename

I suggest you create both images in the beginning and set only one to visible and then switch visibility as necessary to show either moon or sun. Let me know if this helped.

Really appreciated the explanation, Lanzy.

The first method is fine for now. I'll definitely try the other one once I become more comfortable with JS.
In MV in DataManager.saveGameWithoutRescue there is warning if the length of the save data string is equal to or exceeds 200.000 Characters. Suppose you have so many plugins installed, which all add something to the save data, so that it will actually happen, would this be problematic or can you ignore the warning if you know it is okay? Does the warning just exist to inform the game creators that there may be something wrong with their project or is there really a limit to the save file size? I've tested it on the console by adding a string of 400.000 Random Characters to $gamePlayer and it was saved and loaded correctly. So I started to wonder.
@BurningOrca
Sorry if I'm wrong, but I have already accessed sites that froze my browser for some Javascript code that loads a lot of data in a very short time.
Hi everybody,

I was looking through Aesica's plugins on Github to learn from people who are better than me, and I found that they do this after the plugin parameters:
JavaScript:
(function($$)
{
    $$.itemType = {"item":0,"weapon":1,"armor":2,"gold":3};

In the template I got from this forum, I saw the function line having no arguments.
On my side, I tried this bit of code:
JavaScript:
(function($$) {
    $$.stuff = "thing";
    console.log($$);
})();
But the console returns an error at the part where I try to define $$.stuff, saying $$ is undefined.

Can somebody tell me what this $$ is about?
Hi everybody,

I was looking through Aesica's plugins on Github to learn from people who are better than me, and I found that they do this after the plugin parameters:
JavaScript:
(function($$)
{
    $$.itemType = {"item":0,"weapon":1,"armor":2,"gold":3};

In the template I got from this forum, I saw the function line having no arguments.
On my side, I tried this bit of code:
JavaScript:
(function($$) {
    $$.stuff = "thing";
    console.log($$);
})();
But the console returns an error at the part where I try to define $$.stuff, saying $$ is undefined.

Can somebody tell me what this $$ is about?
If you look at the very end of the plugin, it contains the name of the variable that $$ relates to in parentheses afterwards; in the case of autosave, for example, it has (Aesica.Autosave), which was defined earlier in the plugin. The $$ itself doesn't mean anything at all, it's literally just the name of the function variable Aesica chose to represent what gets passed to the function when it's called.

Yours doesn't work because your anonymous function call just has parentheses with no parameter passed, so $$ has nothing to relate to.
I've seen this one but don't remember the syntax (as usual <__<), what's the script line to add a buff to a character?
I've seen this one but don't remember the syntax (as usual <__<), what's the script line to add a buff to a character?

Another question that probably has an easy answer...
This is to set a value to a variable:
Code:
$gameVariables.setValue(ID, value);

How do I add a number instead of just setting it? Like +100%
target.addBuff(effect.dataId, effect.value1)

Original thread: https://forums.rpgmakerweb.com/threads/javascript-questions-that-dont-deserve-their-own-thread.46341/