JavaScript questions that don't deserve their own thread

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,849
Reaction score
9,242
First Language
Indonesian
Primarily Uses
N/A
@raffle your question deserves its own thread. I believe you will get more responses for doing so than asking it here.
 

raffle

Veteran
Veteran
Joined
Oct 25, 2020
Messages
86
Reaction score
24
First Language
English
Primarily Uses
RMMV
@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
 

maliyana

Veteran
Veteran
Joined
Jun 6, 2017
Messages
96
Reaction score
20
First Language
English
Primarily Uses
RMMV
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.)
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,849
Reaction score
9,242
First Language
Indonesian
Primarily Uses
N/A
@maliyana it is going to be plugin support, and that means you better make a new thread. Yes, it deserves one.
 

Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,788
Reaction score
2,224
First Language
English
Primarily Uses
RMMV
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
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,849
Reaction score
9,242
First Language
Indonesian
Primarily Uses
N/A
@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.
 

Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,788
Reaction score
2,224
First Language
English
Primarily Uses
RMMV
Yea I was actually trying to use some(), but it just turns out my formatting was wrong...:kaosigh:
Anyway, thx for the example!
 

dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
1,110
Reaction score
572
First Language
German
Primarily Uses
RMMV
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)
 

Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,788
Reaction score
2,224
First Language
English
Primarily Uses
RMMV
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:
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,001
Reaction score
3,177
First Language
English
Primarily Uses
RMMV
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.
 

Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
773
Reaction score
276
First Language
English
Primarily Uses
RMMV
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.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,001
Reaction score
3,177
First Language
English
Primarily Uses
RMMV
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));
 

Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
773
Reaction score
276
First Language
English
Primarily Uses
RMMV
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));
 

2DMike

Villager
Member
Joined
Aug 1, 2021
Messages
6
Reaction score
3
First Language
English
Primarily Uses
RMMZ
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?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,001
Reaction score
3,177
First Language
English
Primarily Uses
RMMV
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.
 

Coda

Warper
Member
Joined
Dec 1, 2012
Messages
3
Reaction score
0
First Language
English
Primarily Uses
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.
 

Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
773
Reaction score
276
First Language
English
Primarily Uses
RMMV
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?
 

Arctica

Veteran
Veteran
Joined
Jul 19, 2021
Messages
186
Reaction score
302
First Language
English
Primarily Uses
RMMZ
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.
 

Latest Threads

Latest Posts

Latest Profile Posts

I know I'll put one of my game's sprites here to give the illusion that I am a productive member of game society.
handelspriteanim.gif
Preparing untested English localization for DOWNFALLEN.

unknown-43.png
Sometimes I wonder if I feature creep... 225 magic spells is a lot lol.

Forum statistics

Threads
124,500
Messages
1,164,069
Members
163,329
Latest member
milkpowder
Top