JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 97 of 171 View original ↗
  1. TheoAllen said:
    @raffle your question deserves its own thread. I believe you will get more responses for doing so than asking it here.
    You're right :kaocry:I would delete my post here but it seems I can't.. Sorry! I'll make my own thread
  2. I'm using Yanfly's Limited Skill Uses plugin and wanted to know how to allow individual actors/enemies to have unlimited use of a specific skill (ie. Skill Fire Blaster is limited to a few uses for every actor and enemy, except actor Jimbo, who can use it as many times as he wants.)
  3. @maliyana it is going to be plugin support, and that means you better make a new thread. Yes, it deserves one.
  4. Hi, I'm trying to help someone w/ a plugin issue. I need to check if any of an actor's equipment has a baseItemId of a certain value. The problem is I'm not trying to check the array's elements itself, but rather, an element of an element if that makes sense. (element might be the wrong term, sry).

    The array is an actor's ".equips()", which gives you all of the actor's currently equipped gear. For each piece of gear in this array, I need to check if any of the equipment has a baseItemId of x.
    1636711397013.png
  5. @Frostorm use some().
    If that is what you mean.
    Screenshot_798.jpg

    In your case, it probably like
    JavaScript:
    $gameParty.menuActor().equips().some(e => e.baseItemId === 10)
    I don't know if .equips() contains null/undefined value though. Haven't check it.
  6. Yea I was actually trying to use some(), but it just turns out my formatting was wrong...:kaosigh:
    Anyway, thx for the example!
  7. Frostorm said:
    Hi, I'm trying to help someone w/ a plugin issue. I need to check if any of an actor's equipment has a baseItemId of a certain value. The problem is I'm not trying to check the array's elements itself, but rather, an element of an element if that makes sense. (element might be the wrong term, sry).

    The array is an actor's ".equips()", which gives you all of the actor's currently equipped gear. For each piece of gear in this array, I need to check if any of the equipment has a baseItemId of x.
    View attachment 206469
    did you try?:
    JavaScript:
    $gameParty.menuActor().equips()[0].baseItemId === x
    // "x" should be the number which you are looking for
    // this returns true or false and can be put in a "if condition"
    if ($gameParty.menuActor().equips()[0].baseItemId === x) {execute stuff here if true};
    Screenshot_1.png
    (perhaps i missunderstood something idk)
  8. Yea I can do single line test like that just fine. I was just bad at manipulating the actor's equips() array before. This is for a shop plugin btw. When shopping, it's supposed to check each slot and see if any of them has a baseItemId equal to the currently selected shop item's ID. So I was having a hard time getting it all packaged neat and tidy. Like I wasn't sure how to reference the item currently being selected, etc... >.>

    You can see all my failed attempts here:
    MV - YEP Shop Menu Core - Show Equip Status?
  9. dopan said:
    did you try?:
    That only checks a specific slot, it won't return true if any of the slots have the appropriate item. You could use that syntax and check each individual equipment slot, but that's what the inherent some() function is designed to handle.
  10. Quick question, what would the eval be to apply a state to all allies and enemies? Would this need a loop to accomplish?

    For context, I'm using Yanfly's Buff and State Core. When a state is applied, I'm looking for it to apply a different state to everyone. Likewise, when the first state is removed, the second state is removed from everyone.
  11. Vis_Mage said:
    Quick question, what would the eval be to apply a state to all allies and enemies?
    You can use the inherent array foreach() function. So, for example:
    Code:
    $gameTroop.aliveMembers().foreach(battler => battler.addState(X));
  12. ATT_Turan said:
    You can use the inherent array foreach() function. So, for example:
    Code:
    $gameTroop.aliveMembers().foreach(battler => battler.addState(X));
    Hmm, trying that out, I'm getting the following error:
    TypeError: $gameTroop.aliveMembers(...).foreach is not a function

    I've currently just changed the state value, is there any other changes that I needed to make?

    Code:
    $gameTroop.aliveMembers().foreach(battler => battler.addState(32));
  13. ForEach function has capital E.
  14. For MZ/JS.

    Bit of a long shot but does anyone know a way of triggering script between battle menus? For example, hitting 'magic' would trigger an animation as it displays the list of spells. Is there a means to insert script between the player the selecting the option and it displaying?
  15. 2DMike said:
    Bit of a long shot but does anyone know a way of triggering script between battle menus?
    You should be able to do this. You'll want to tie it into probably the commandWindow handler. If that's not quite enough for you to go on, this deserves its own plugin request thread.
  16. Is there an MV equivalent of VXA's Graphics.freeze and Graphics.transition? The main point is to transition with an effect without going through a black screen.
  17. Bit of an odd question here. Is there a script call that I can use to check each variable within a convective range of IDs (such as variables 800-872) to see if they are greater than 0, and if so, add the value of variable 873 to them?
  18. Pardon me, my brain is running at 35% and I should sleep, so I can only offer something a bit middle of the road for you: You could set up an array with each element being the IDs and parse them through a loop and use $gameVariables.value(array[index])(might be a cleaner way of doing that) and do whatever other logic you need from there.
  19. Vis_Mage said:
    Is there a script call that I can use to check each variable within a convective range of IDs (such as variables 800-872) to see if they are greater than 0, and if so, add the value of variable 873 to them?
    I'm confused by your wording as to whether you want to add the value of 873 to each of those other variables IFF they are greater than 0; or if you want to get one number that is the sum of all of those?

    Either way, you'd just access the variables array directly: $gameVariables._data[index]

    So you can make a loop that goes through that and does whatever you intended to say, or use the JavaScript inherent array functions, whatever.