Hi all! I'm trying to create something of a utility menu in my game. I have two options for finding out if I had learned a skill: by its ID # or by typing it out. I got the ID part working great, but the eval for finding a skill by a string typed out is where I need help. Any reply to help would be appreciated!
Eval for checking if a skill is learned by skill name?
RPG Maker MV SupportWould this work for you?
Note:
Replace both of the Y with the object (i.e. the character) you are checking (see example below)
Replace 'Strike' with the name of the skill in question, keep in mind that the ' ' are important to keep
So it could look like this for example:
or in a Yanfly eval for example:
JavaScript:
Y.isLearnedSkill(Y.skills().find(x => x.name == 'Strike').id)
Note:
Replace both of the Y with the object (i.e. the character) you are checking (see example below)
Replace 'Strike' with the name of the skill in question, keep in mind that the ' ' are important to keep
So it could look like this for example:
JavaScript:
$gameParty.members()[0].isLearnedSkill($gameParty.members()[0].skills().find(x => x.name == 'Ice Beam').id)
or in a Yanfly eval for example:
JavaScript:
user.isLearnedSkill(user.skills().find(x => x.name == 'Devastate').id)
For a certain actor:
For the entire Party:
Code:
if (actor.skills().find(skill => skill.name == 'Your Skill Name')) {
// true
} else {
// false
}
For the entire Party:
Code:
if ($gameParty.members().find(actor => actor.skills().find(skill => skill.name == 'Your Skill Name'))) {
...
Thank you all so much for the replies. I'll give these a test and let yall know how it goes. 🙂
EDIT: What I'm actually trying to go for is yes, find a string by its name, but with name input processing to where I type it, it saves it in a variable and looks for the string inside that variable.
i.e.: $gameParty.leader().isLearnedSkill($gameParty.leader().skills().find(x => x.name == $gameVariables.value(1)).id)
I'm going to test this though first to see if it works.
EDIT: What I'm actually trying to go for is yes, find a string by its name, but with name input processing to where I type it, it saves it in a variable and looks for the string inside that variable.
i.e.: $gameParty.leader().isLearnedSkill($gameParty.leader().skills().find(x => x.name == $gameVariables.value(1)).id)
I'm going to test this though first to see if it works.
Okay, so you call an event with Name Input Processing, then replace the portion of Aerosys' code that says "Your Skill Name" with that actor's name.
So if you do Name Input Processing -> Actor 69 is the dummy actor you're storing it in, you'd replace "Your Skill Name" with
$gameActors.actor(69).name()It worked! Thank you all so very, very much!
This method worked! Thank you all so much! Love ya guys!
Of course, I don't want to contradict you, but are you sure this is always working? When you don't have a skill with the desired name, "find" will return "undefined", and then crash because you are trying to read "id" from undefined, which is not allowed.
Original thread: https://forums.rpgmakerweb.com/threads/eval-for-checking-if-a-skill-is-learned-by-skill-name.161514/