JavaScript questions that don't deserve their own thread

Try using

JavaScript:
$dataQuests[questID];

This might just return the entire quest, rather than the name.
I don't know how it's structured. If you can use that code above in the console and post a screenshot, then I can give u more details.
It was $dataQuests[questId].name. Thank you very much!

In case anybody's having this issue in the future, here's what I'm putting in the Lunatic Mode code that's executed when a quest is added:
JavaScript:
var cmd = new Game_Interpreter();
var line = 'New quest: ' + $dataQuests[questId].name;
cmd.pluginCommand('GabText', [line]);
cmd.pluginCommand('ShowGab');
This will display the Gab window "New quest: " followed by the name of the quest (with its text codes) exactly like you entered it in the plugin settings of the Quest Journal plugin.
Hi,

How do I clear/erase a drawn rectangle?:

Window_Label.prototype.drawDarkRect = function(dx, dy, dw, dh) {
var color = this.textColor(1);
this.changePaintOpacity(false);
this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
this.changePaintOpacity(true);
};



this.createContents();
this.drawDarkRect(0, 0, 600, this.lineHeight());
Hi,

How do I clear/erase a drawn rectangle?:

Window_Label.prototype.drawDarkRect = function(dx, dy, dw, dh) {
var color = this.textColor(1);
this.changePaintOpacity(false);
this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
this.changePaintOpacity(true);
};



this.createContents();
this.drawDarkRect(0, 0, 600, this.lineHeight());

myWindow.contents.clearRect(x, y, width, height)
Is there a way to check if a skill's targeting type is 1 enemy and not anything else?

I want to make a "chance to taunt" state that can redirect skills to the battler that gave it using user.currentAction().setTarget(origin.index()) but remove the ability to redirect skills that hit random targets or all of them because that wouldn't make sense.

EDIT: solved.
JavaScript:
<Custom Action Start Effect>
action = user.currentAction();
//if the scope isn't "1 enemy", action._targetIndex = -1
//otherwise, it's the index of the target, 0 or higher
if(action._targetIndex >= 0) {
  if(Math.random() <= 0.5) { //roll for redirection
    action.setTarget(origin.index()); //we change the target to origin
  }
}
</Custom Action Start Effect>
Is there a way to check if a skill's targeting type is 1 enemy and not anything else?

I want to make a "chance to taunt" state that can redirect skills to the battler that gave it using user.currentAction().setTarget(origin.index()) but remove the ability to redirect skills that hit random targets or all of them because that wouldn't make sense.

I don't know what plugins you are using, but generally you can check the scope of a skill like this:

JavaScript:
$dataSkills[x].scope // scope = 1 is for targeting 1 enemy
I don't know what plugins you are using, but generally you can check the scope of a skill like this:

JavaScript:
$dataSkills[x].scope // scope = 1 is for targeting 1 enemy
It was all using the Buffs and States Core. I found my own solution in the meantime, so I edited it into my message. It took a lot of console.log() commands, but despite how hard the console makes everything slow down, I found a way.

Thank you for your time, though.
With YEP_BattleEngineCore how do I center the battle text?
XQHFEcT.png


I hate how it looks on the left but I looked everywhere and I couldn't find an option to switch its position or maybe I'm just a dummy!
With YEP_BattleEngineCore how do I center the battle text?

I hate how it looks on the left but I looked everywhere and I couldn't find an option to switch its position or maybe I'm just a dummy!
Write <CENTER> (case-sensitive, so make sure it's in all caps) anywhere in the message.
@CHKNRAVE That was it thank you very much! I am indeed a dummy. :LZSproud:
Hi! I'm looking to inflict an "exhaustion" status on actors when their MP reaches 0. I'm using Yanfly's Skill and States Core, and I'm assuming it could be done with a passive condition switch. I just don't know what would work in the condition box. Any ideas would be appreciated 😀 (RPG MAKER MZ)

1606839549721.png
Sure, put this state as a passive on whoever can get exhausted this way. In the state's notes, write this:
JavaScript:
<Custom Passive Condition>
if(user.mp <= 0) {
    condition = true;
} else {
    condition = false;
}
</Custom Passive Condition>

EDIT: The code may slightly differ because you're on MZ. Sorry, I didn't catch that in your message.
Sure, put this state as a passive on whoever can get exhausted this way. In the state's notes, write this:
JavaScript:
<Custom Passive Condition>
if(user.mp <= 0) {
    condition = true;
} else {
    condition = false;
}
</Custom Passive Condition>

EDIT: The code may slightly differ because you're on MZ. Sorry, I didn't catch that in your message.

I’ll give it a try after work and see. Thank you in any case 🙂

EDIT: Success! Just had to change the brackets


<JS Passive Condition>

if(user.mp <= 0) {

condition = true;

} else {

condition = false;

}

</JS Passive Condition>

Thank you 😀
Hey, two quick questions:

1. Is there a bit of code that can be used to change an events z axis? What I'm trying to achieve is have an event show up above a picture

2. Is there an easy bit of code I can use to "shuffle" a set of 9 variables? (As in, all of the values of these variables are randomly redistributed to one of those 9 variables)
Hey, two quick questions:

1. Is there a bit of code that can be used to change an events z axis? What I'm trying to achieve is have an event show up above a picture

2. Is there an easy bit of code I can use to "shuffle" a set of 9 variables? (As in, all of the values of these variables are randomly redistributed to one of those 9 variables)

The events and the images that are attached to events are 2 seperate things. What you can do is, take the image of the event and move that to a certain z layer:

SceneManager._scene._spriteset._characterSprites[spriteIndex].z = zLayer;

About shuffling arrays:
I had to look it up, since apparently there is a so called Durstenfeld shuffle method out there. I modified it a little to be able to accept beginning and end indexes within the array to be shuffled.

JavaScript:
randomizeVariables = function (startVariable, endVariable) {
    shuffleArray($gameVariables._data, startVariable, endVariable);
}
/* Randomize array in-place using modified Durstenfeld shuffle algorithm
    (modified to accept beginning and end within the array)
*/
function shuffleArray(array, startIndex, endIndex) {
    for (let i = endIndex; i >= startIndex; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
}

Ok so once you have that you can simply do:

randomizeVariables(15, 20) // this randomizes variables 15 to 20


That was an interesting task lol

//Edit:
Just realized you may have not even meant the game Variables of MV but just any random variables lol.
//Edit:
Just realized you may have not even meant the game Variables of MV but just any random variables lol.

Thank you for your help! I have a couple of questions about the two, though.

A bit silly, but could you give me an example of the first one in use? I'm having a hard time figuring out where it should be ran from/it's syntax. To better illustrate what I'm trying to do with it, I'm hoping to run the code from one event, that will make a dozen or so other events on the same map change their Z position to be over pictures.

As for the second, I was indeed talking about MV variables. Something kinda interesting that I'm not sure was intentional or not, it seems that when the variables shuffle, values can show up repeatedly, or not at all. For example, if I'm shuffling variables with values of 1, 2, and 3, the outcome could end up being something like 1 3 3, with 2 being left out.
Thank you for your help! I have a couple of questions about the two, though.

A bit silly, but could you give me an example of the first one in use? I'm having a hard time figuring out where it should be ran from/it's syntax. To better illustrate what I'm trying to do with it, I'm hoping to run the code from one event, that will make a dozen or so other events on the same map change their Z position to be over pictures.

As for the second, I was indeed talking about MV variables. Something kinda interesting that I'm not sure was intentional or not, it seems that when the variables shuffle, values can show up repeatedly, or not at all. For example, if I'm shuffling variables with values of 1, 2, and 3, the outcome could end up being something like 1 3 3, with 2 being left out.

No problem. Next time please clarify as to how javascript proficient you are so people know whether or not they should respond with extensive instructions or not.

You can always test code in the developer console by pressing F8 when the game is running.
Then click on the "console" tab and enter code.

If you want to run code from an event you simply insert a script (found under the category "advanced") within the event. In that script you insert the code.

Ok, so ignore the last code line I provided, I found a better one that actually works lol:

$gameMap._events[eventId]._priorityType = 2;

So if you for example want to change the z layer of an event with the id 012 you simply use:

$gameMap._events[12]._priorityType = 2;

._priorityType has to be set to 2 to be over the pictures. If that doesn't work, try 3 instead.


For the second issue:
Note that the shuffling only works if the variables are in a consecutive order. You can't shuffle variables 4, 60 and 100. It has to be 1,2,3 or 50,51,52.
If that doesn't solve the problem, please send me a screenshot of how you use it.
Hello, makers.

Is there a way to make the Map Select Equip plugin work in battle?

I want to give the player the ability to change their current weapon in battle, but from one specific weapon type to the same specific weapon type.
I had the eventing ready, the goal was to give this action a cost so it was all handled by skill calling a common event, but then I reach the plugin command MapSelectEquip 20 weapon and it's as if the command gets entirely ignored. As if I just pressed Escape, according to how I handle that situation.

Workaround found using events and many hidden items.
How i can force the Miss Popups?
When using the Select Item command script $gameMessage.setItemChoice(varID, n);, how do I make the game wait for the selection to be made?

I've put the code in a Custom Apply Effect (I'm addicted to these), and the console.log() command I put right after (to monitor the new value of the variable) displays 0 (the default value I set up) in the console immediately.

Here's the portion of code where it goes wrong. I'm supposed to process the value of variable number 20 right after that.

JavaScript:
$gameVariables.setValue(20, 0); //the default value
$gameMessage.add("selection"); //it displays along with the item choice window
$gameMessage.setItemChoice(20, 3); //the user has to select a hidden item A
$gameParty._interpreter.setWaitMode('message'); //I looked things up and this was supposed to work
console.log($gameVariables.value(20)); //that's how it displays a 0 while the item choice window is still open

Note: it's only going to be executed in battle, nowhere else.
Is there any way I can make the texts and icons on the top bigger and the ones at the bottom smaller?

Spoiler: Image
zwc1254cp5361.jpg

I know you can change the font in the setting, but that's for all the texts in the game and I'm not sure if I want to make it any lower. Just wanna change the text size in the menu.

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