JavaScript questions that don't deserve their own thread

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
509
Reaction score
485
First Language
English
Primarily Uses
RMMZ
Any script that clears the current balloon from the player?
This should work:
JavaScript:
for (const sprite of SceneManager._scene._spriteset._balloonSprites) {
    if (sprite._target._character == $gamePlayer) {
        SceneManager._scene._spriteset.removeBalloon(sprite);
    }
}
 

BombchuSquad

Villager
Member
Joined
Jan 25, 2022
Messages
17
Reaction score
4
First Language
English
Primarily Uses
RMMZ
Hi, everyone! I hope this is the right place for this question, and that I'm posting this correctly. I normally don't spend much time on forums. Anyway, I'm using VisuStella's Skill Learn plugin for MZ. I basically understand how to use it, but I have an issue with the AP, CP, and JP distributions. I'm tempted to have my characters learn their skills thru items/equipment/gold instead, but we'll see.

The problem I have with AP is that eventually, every skill will be purchased, yet the player will still be earning useless points. I don't have a plugin for extra currencies. I haven't found a way to transform AP into another use like a special shop so that the player can use them for other purposes besides skills. If this is possible, would you know how to do it?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,936
Reaction score
3,138
First Language
English
Primarily Uses
RMMV
Hi, everyone! I hope this is the right place for this question, and that I'm posting this correctly. I normally don't spend much time on forums.
Welcome! Unfortunately, it's not really - the thread title is JavaScript questions (and your post doesn't refer to any JavaScript code), and the first post says:
If you need help getting a plugin working, please start a NEW thread and include a link to where you downloaded the plugin from.

So you're already in the Plugin Support forum, just click the link on the top of the page to go to the forum instead of inside this thread, then on the right is a big blue button that says Post Thread.
 

BombchuSquad

Villager
Member
Joined
Jan 25, 2022
Messages
17
Reaction score
4
First Language
English
Primarily Uses
RMMZ
Welcome! Unfortunately, it's not really - the thread title is JavaScript questions (and your post doesn't refer to any JavaScript code), and the first post says:


So you're already in the Plugin Support forum, just click the link on the top of the page to go to the forum instead of inside this thread, then on the right is a big blue button that says Post Thread.
Ah, okay. Thank you!
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,847
Reaction score
12,377
First Language
English
Primarily Uses
RMMZ
I am trying to check who is the leader of the party. However, even if the conditional should result in a yes, it gives the text for the 'Else' branch. This is the code I've used in the conditional command:
Code:
$gameParty.leader === $gameActors[1]

Can someone please correct this for me.

Thank you
 

BombchuSquad

Villager
Member
Joined
Jan 25, 2022
Messages
17
Reaction score
4
First Language
English
Primarily Uses
RMMZ
I am trying to check who is the leader of the party. However, even if the conditional should result in a yes, it gives the text for the 'Else' branch. This is the code I've used in the conditional command:
Code:
$gameParty.leader === $gameActors[1]

Can someone please correct this for me.

Thank you
I can't help with your code, but I am replying to your message because I saw your list of games. I own Undefeated and wanted to let you know! Cool game!
 
  • Like
Reactions: Kes

Eternidade_1

Villager
Member
Joined
Aug 1, 2014
Messages
23
Reaction score
5
First Language
portuguese
Primarily Uses
RMMV
how to check if the equipment of the group leader? not using (has.weapon,has.armor)
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,936
Reaction score
3,138
First Language
English
Primarily Uses
RMMV
how to check if the equipment of the group leader? not using (has.weapon,has.armor)
What are you asking? The only items you can equip on an actor are weapons and armor, so it seems you already know the answer - you give no other explanation of what you're trying to do.
 

Fionn23

Eternal Noob
Veteran
Joined
Dec 11, 2021
Messages
102
Reaction score
51
First Language
Filipino
Primarily Uses
RMMZ
Let's say I add a single trait on a state called State A. How will I able to change the trait's value inside State A via Javascript?
 

Boonty

Veteran
Veteran
Joined
Oct 10, 2018
Messages
155
Reaction score
56
First Language
French
Primarily Uses
RMMV
Hello there.

Is there a way to change a state icon in-game ? I search on the forum but was not able to find anything relevant.

Thanks for your help
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,936
Reaction score
3,138
First Language
English
Primarily Uses
RMMV
Let's say I add a single trait on a state called State A. How will I able to change the trait's value inside State A via Javascript?
You can't really. The traits are drawn from the JSON database files, so just modifying them via JavaScript during your game won't have a lasting change.

You'll need to look for a plugin - I think I recall Galv and Shaz had them...I don't recall if they were for MV, MZ or both, but if you Google dynamic traits you'll find stuff.
Is there a way to change a state icon in-game ? I search on the forum but was not able to find anything relevant.
Similar to the answer above, the icons are read from the database when they're referenced. The easiest way to do something like this would be to create duplicate states with the different icons and actually change the state during play.
 

Boonty

Veteran
Veteran
Joined
Oct 10, 2018
Messages
155
Reaction score
56
First Language
French
Primarily Uses
RMMV
Similar to the answer above, the icons are read from the database when they're referenced. The easiest way to do something like this would be to create duplicate states with the different icons and actually change the state during play.

That was my back-up plan.

Thanks a lot for your quick answer.
 

Fionn23

Eternal Noob
Veteran
Joined
Dec 11, 2021
Messages
102
Reaction score
51
First Language
Filipino
Primarily Uses
RMMZ
You can't really. The traits are drawn from the JSON database files, so just modifying them via JavaScript during your game won't have a lasting change.

You'll need to look for a plugin - I think I recall Galv and Shaz had them...I don't recall if they were for MV, MZ or both, but if you Google dynamic traits you'll find stuff.
Actually, that's perfect for me. As I want the change to my traits to be temporary.
 

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
509
Reaction score
485
First Language
English
Primarily Uses
RMMZ
the icons are read from the database when they're referenced.
This is actually not quite accurate (depending on how you want to define "the database"). The database files are only read one time, when the game first boots up. After that, the contents are all stored in memory, as JavaScript objects, and are read from memory each time they are referenced. This means that you actually can change the properties of those objects in memory, and the changes will persist until the next time the game boots up. At least, this is definitely true for MZ. I'm too lazy to check MV, but I'm reasonably certain it will apply to MV as well.

Whether or not that level of persistence is sufficient is definitely situational though. But for example, if it's a state that can only exist in battle, I don't see any reason why changing the icon via JavaScript would be a problem.

@Boonty
Please take note of what I mentioned above. If it's not an issue, then what you're asking for can be accomplished with this script call:
JavaScript:
$dataStates[stateId].iconIndex = newIconId;
You'll want to replace stateId with the actual numerical ID of the state, and newIconId with the actual numerical ID of the new icon that you want to use.

@Fionn23
Also please take note of what I mentioned above. If that's okay, then here is what you need to know to edit a state's trait. Each state has a traits property, which is an array of objects that represent each trait. Each trait object has three properties: code, dataId, and value.

The code represents the type of trait, and the dataId represents the sub-option within that type, and the value represents the intensity. So if you're looking at the traits GUI in your database, the code represents what you selected with a radio button (for example, "Ex-Parameter"), and the dataId represents what you selected in the dropdown box next to that option (for example, "HP Regeneration"), and the value represents whatever you type in the input box (for example, -10%).

I don't have a reliable list of codes and dataIds, so if you want to change those, you'll have to do your own research. But if you don't need to change the type/effect of the trait, and you just need to change the intensity (the value), then that's easy enough:
JavaScript:
$dataStates[stateId].traits[index].value = newValue;
The trait index starts at 0, and is based on whatever order you entered the traits in the database. And newValue is usually going to be a floating point number representing a ratio.

So for example, if I want to change the Poison state (the one from a default new project in MZ) so that it's trait reduces HP by -20% each regen, instead of the default -10%, then I'd use this script call:
JavaScript:
$dataStates[4].traits[0].value = -0.2;
 
Last edited:

Fionn23

Eternal Noob
Veteran
Joined
Dec 11, 2021
Messages
102
Reaction score
51
First Language
Filipino
Primarily Uses
RMMZ
This is actually not quite accurate (depending on how you want to define "the database"). The database files are only read one time, when the game first boots up. After that, the contents are all stored in memory, as JavaScript objects, and are read from memory each time they are referenced. This means that you actually can change the properties of those objects in memory, and the changes will persist until the next time the game boots up. At least, this is definitely true for MZ. I'm too lazy to check MV, but I'm reasonably certain it will apply to MV as well.

Whether or not that level of persistence is sufficient is definitely situational though. But for example, if it's a state that can only exist in battle, I don't see any reason why changing the icon via JavaScript would be a problem.

@Boonty
Please take note of what I mentioned above. If it's not an issue, then what you're asking for can be accomplished with this script call:
JavaScript:
$dataStates[stateId].iconIndex = newIconId;
You'll want to replace stateId with the actual numerical ID of the state, and newIconId with the actual numerical ID of the new icon that you want to use.

@Fionn23
Also please take note of what I mentioned above. If that's okay, then here is what you need to know to edit a state's trait. Each state has a traits property, which is an array of objects that represent each trait. Each trait object has three properties: code, dataId, and value.

The code represents the type of trait, and the dataId represents the sub-option within that type, and the value represents the intensity. So if you're looking at the traits GUI in your database, the code represents what you selected with a radio button (for example, "Ex-Parameter"), and the dataId represents what you selected in the dropdown box next to that option (for example, "HP Regeneration"), and the value represents whatever you type in the input box (for example, -10%).

I don't have a reliable list of codes and dataIds, so if you want to change those, you'll have to do your own research. But if you don't need to change the type/effect of the trait, and you just need to change the intensity (the value), then that's easy enough:
JavaScript:
$dataStates[stateId].traits[index].value = newValue;
The trait index starts at 0, and is based on whatever order you entered the traits in the database. And newValue is usually going to be a floating point number representing a ratio.

So for example, if I want to change the Poison state (the one from a default new project in MZ) so that it's trait reduces HP by -20% each regen, instead of the default -10%, then I'd use this script call:
JavaScript:
$dataStates[4].traits[0].value = -0.2;
This is working. Thanks!

I have a question though. Upon testing this code, I confirmed that loading a save file will remove the changes to the traits. However, the changes weren't removed when starting another battle after applying the changes.

Is there a quick way to reset the traits whenever I like? Like in a Javascript function?

Edit: I'll probably just store the default values in a variable XD
 
Last edited:

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
509
Reaction score
485
First Language
English
Primarily Uses
RMMZ
This is working. Thanks!

I have a question though. Upon testing this code, I confirmed that loading a save file will remove the changes to the traits. However, the changes weren't removed when starting another battle after applying the changes.

Is there a quick way to reset the traits whenever I like? Like in a Javascript function?

Edit: I'll probably just store the default values in a variable XD
I would just store the original value into a variable, before you overwrite it, and then restore it when you want to. You *could* re-load the states from the States.json file, but that wouldn't be a particularly performance-conscious thing to do.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,936
Reaction score
3,138
First Language
English
Primarily Uses
RMMV
This is actually not quite accurate (depending on how you want to define "the database"). The database files are only read one time, when the game first boots up. After that, the contents are all stored in memory, as JavaScript objects, and are read from memory each time they are referenced. This means that you actually can change the properties of those objects in memory, and the changes will persist until the next time the game boots up. At least, this is definitely true for MZ. I'm too lazy to check MV, but I'm reasonably certain it will apply to MV as well.

Whether or not that level of persistence is sufficient is definitely situational though.
You are correct. That is how it works in MV also, and it is what I meant. I just presume if someone says they want to change something in their game that it will stay changed :wink:

And then if it's supposed to be temporary, but you want it to reset within this play session the next time the state is referenced, you have to do extra code for that and...blah.
 

Latest Threads

Latest Posts

Latest Profile Posts

The game's opening, now fully polished! :LZScheeze:





Aaand, here's me working on it in today's "Game Making Every Day" video! :LZSooo:

Hello! Can anyone help me? I followed making cooking tutorial for RPG Maker MV. But for some reason buff state that food gives doesn't work in overworld. It disappears. What am I supposed to do?
A shotgun is not a rifle. Huh.
SIGH its so hard to convince my friend that making a game for fun and making one to sell takes different planning. I don't care about weird bothersome ways of doing things in a game made for fun, but when you are planning to market it, there is some stuff that you just have to streamline or cut out.
It might be a little bit boring and tedious, but building that database of armor, items, weapons and skills are super important.

Forum statistics

Threads
124,399
Messages
1,163,348
Members
163,198
Latest member
Oneesama
Top