JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 105 of 171 View original ↗
  1. 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?
  2. BombchuSquad said:
    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:
    Shaz said:
    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.
  3. ATT_Turan said:
    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!
  4. 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
  5. Kes said:
    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!
  6. @Kes

    This should do what you want:

    JavaScript:
    $gameParty.leader() == $gameActors.actor(1)
  7. @bombchThank you! It's kind of you to say so.

    @ScorchedGround That works perfectly. Thank you for your help.
  8. how to check if the equipment of the group leader? not using (has.weapon,has.armor)
  9. Eternidade_1 said:
    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.
  10. 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?
  11. 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
  12. Fionn23 said:
    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.
    Boonty said:
    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.
  13. ATT_Turan said:
    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.
  14. ATT_Turan said:
    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.
  15. ATT_Turan said:
    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;
  16. Thanks! Will try this.
  17. Arthran said:
    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
  18. Fionn23 said:
    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.
  19. Arthran said:
    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.
  20. @Arthran Thanks for your explanations. You saved me a lot of time with your intervention :)