JavaScript questions that don't deserve their own thread

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
154
Reaction score
83
First Language
French
Primarily Uses
RMMV
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.
 

MikeMakes

Veteran
Veteran
Joined
Sep 30, 2015
Messages
186
Reaction score
46
First Language
English
Primarily Uses
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());
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
135
Reaction score
57
First Language
English
Primarily Uses
RMMV
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)
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
154
Reaction score
83
First Language
French
Primarily Uses
RMMV
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>
 
Last edited:

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
135
Reaction score
57
First Language
English
Primarily Uses
RMMV
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
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
154
Reaction score
83
First Language
French
Primarily Uses
RMMV
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.
 

raffle

Veteran
Veteran
Joined
Oct 25, 2020
Messages
37
Reaction score
6
First Language
English
Primarily Uses
RMMV
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!
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
154
Reaction score
83
First Language
French
Primarily Uses
RMMV
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.
 

raffle

Veteran
Veteran
Joined
Oct 25, 2020
Messages
37
Reaction score
6
First Language
English
Primarily Uses
RMMV
@CHKNRAVE That was it thank you very much! I am indeed a dummy. :LZSproud:
 

mmiller9280

Veteran
Veteran
Joined
Sep 21, 2020
Messages
43
Reaction score
35
First Language
English
Primarily Uses
RMMZ
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 :D (RPG MAKER MZ)

1606839549721.png
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
154
Reaction score
83
First Language
French
Primarily Uses
RMMV
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.
 

mmiller9280

Veteran
Veteran
Joined
Sep 21, 2020
Messages
43
Reaction score
35
First Language
English
Primarily Uses
RMMZ
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 :D
 
Last edited:

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
596
Reaction score
198
First Language
English
Primarily Uses
RMMV
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)
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
135
Reaction score
57
First Language
English
Primarily Uses
RMMV
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.
 
Last edited:

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
596
Reaction score
198
First Language
English
Primarily Uses
RMMV
//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.
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
135
Reaction score
57
First Language
English
Primarily Uses
RMMV
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.
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
154
Reaction score
83
First Language
French
Primarily Uses
RMMV
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.
 
Last edited:

STARFALL

STARFALL
Veteran
Joined
Jul 6, 2020
Messages
127
Reaction score
17
First Language
spanish
Primarily Uses
RMMV
How i can force the Miss Popups?
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
154
Reaction score
83
First Language
French
Primarily Uses
RMMV
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.
 

Mr. Detective

NATO Special Operative
Veteran
Joined
Sep 9, 2012
Messages
741
Reaction score
257
First Language
English
Primarily Uses
N/A
Is there any way I can make the texts and icons on the top bigger and the ones at the bottom smaller?


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.
 

Latest Threads

Latest Posts

Latest Profile Posts

So, explain why we can no longer use BBC code or smilies in our posts? This sparks much sadness...
Are we now stuck with WYSIWYG ? I cannot revert back my posts to good old raw text ?
I'm wondering if I may be putting too many things into one map. A story, within a story, within a story . . . it's fun, but I can't shake the feeling that it may be better to scrap some of it, and use it for another map. I'm not sure what to do.

And the beginning of a nearly complete grid system dawns.

I want to add a thin pixel border around the entire region. Like across all blue highlights that connect and red attack highlights that connect.

Forum statistics

Threads
107,787
Messages
1,032,198
Members
139,939
Latest member
Mineformer
Top