Script call for if actor does not have skill

I am setting up an event and I find that I need to be able to check if an actor; based on a variable, does not have a skill. So my question is this.


How would I set up in the conditional branch script call a script that checks the actor, based on a variable I set up earlier in the event, and finds if they do not have a skill?


Thank you for any help.
In a script call in conditional branch, use this.

$gameParty.members()[0].skills().indexOf($dataSkills[$gameVariables._data[4]]) >= 0;

this will check party member with the index of 0, for the skill with the Id of variable #4.
In a script call in conditional branch, use this.

 



//this will get the actor at index 0(player character), and check if he has the skill with the id equal to the number in game variable 4.
$gameParty.members()[].skills().indexOf($dataSkills[$gameVariables._data[4]]) >=

Thank you. Is it possible to get the actor from a variable too? Because the actor I'm checking isn't always going to be the player character.


Also can I change it to check if the actor does not have the skill?


I keep getting an error every time I try and use this. It says "Unexpected end of input".
weird, the numbers keep disappearing but anyways.

$gameVariables._data[variable id]


stick that inside the brackets for $gamePart.members, just like I did with $dataSkills, and the player checked will be the index of whatever variable ID you specify.


edit: just remember, the index starts with 0, so the top party member, will always be 0, the one below him 1 etc etc.

edit2: oh yeah, and if the variable isn't specified(or the variable is not a party member that doesnt exist) then you'll get an error. 
weird, the numbers keep disappearing but anyways.

$gameVariables._data[variable id]


stick that inside the brackets for $gamePart.members, just like I did with $dataSkills, and the player checked will be the index of whatever variable ID you specify.


edit: just remember, the index starts with 0, so the top party member, will always be 0, the one below him 1 etc etc.

edit2: oh yeah, and if the variable isn't specified(or the variable is not a party member that doesnt exist) then you'll get an error. 

The variables are all set early on in the event so they can never equal a party member who's not in the party.


After adding the 0's it's giving me a different error. " Cannot read property 'skills' of undefined".
Can you copy paste the codeyou typed into the conditional branch for me plz? 🙂
Can you copy paste the codeyou typed into the conditional branch for me plz? 🙂

Here's the code:


$gameParty.members()[$gameVariables._data[489]].skills().indexOf($dataSkills[$gameVariables._data[486]]) >= ;


There's 0's in the code but they're not showing up here.


Here's the code again:


$gameParty.members()[$gameVariables._data[489]].skills().indexOf($dataSkills[$gameVariables._data[486]]) >= 0;
what number is the variable 489 set to?
and what number is 486 set to,


can you try using a script call before the conditional branch, with this in it.
console.log($gameVariables._data[489]);


and make another one, using,


console.log($gameVariables._data[486]);


then check the console, and the top number shown should be 489, the bottom 486, make sure that these numbers are between(for actors variable, if your party size is 4) 0 and 3, and for  skill variable, make sure its within 0 to however big your skill list is.
 


also you've got the end wrong the code should be, $gameParty.members()[$gameVariables._data[489]].skills().indexOf($dataSkills[$gameVariables._data[486]]) >= 0


(or maybe the forum cut out the 0, that's what happened in my first post lol), anyways I just tested this out myself, and didn't have any error, so I think one of the variables might be off. just make sure to add the 0 at the end if it's not there lol.
what number is the variable 489 set to?
and what number is 486 set to,


can you try using a script call before the conditional branch, with this in it.
console.log($gameVariables._data[489]);


and make another one, using,


console.log($gameVariables._data[486]);


then check the console, and the top number shown should be 489, the bottom 486, make sure that these numbers are between(for actors variable, if your party size is 4) 0 and 3, and for  skill variable, make sure its within 0 to however big your skill list is.
 


also you've got the end wrong the code should be, $gameParty.members()[$gameVariables._data[489]].skills().indexOf($dataSkills[$gameVariables._data[486]]) >= 0


(or maybe the forum cut out the 0, that's what happened in my first post lol), anyways I just tested this out myself, and didn't have any error, so I think one of the variables might be off. just make sure to add the 0 at the end if it's not there lol.

Just tested it and it's working now. It was because the actor variable was set to 1 and not 0. Thanks for your help.


Is it possible to switch something in that code to have it check for if the skill is not learned?


Because right now it's checking to see if it's learned and it would make things a bit easier if I could have it check to see if the skill isn't learned.
$gameParty.members() checks how many actors are in your party currently, if you only have 1 actor in your party, using a value of 1 would cause an error, you'd need to use 0,


$gameParty.members() works differently than $gameActors, if you want to get a specific actor, not a party member use $gameActors._data[actorID] for example, using your actor list above, if you wanted to check the actor Lilly, to see if they have skill ID 5  you'd use


$gameActors._data[10] .skills().indexOf($dataSkills[5]) >= 0


apologies maybe I should have told you to use gameActors first, not sure what I was thinking xD also sorry again for not using the code boxes, but for some reason they're not working exactly right?(at least not on my end not sure if it's just me or.. ._.)
$gameParty.members() checks how many actors are in your party currently, if you only have 1 actor in your party, using a value of 1 would cause an error, you'd need to use 0,


$gameParty.members() works differently than $gameActors, if you want to get a specific actor, not a party member use $gameActors._data[actorID] for example, using your actor list above, if you wanted to check the actor Lilly, to see if they have skill ID 5  you'd use


$gameActors._data[10] .skills().indexOf($dataSkills[5]) >= 0


apologies maybe I should have told you to use gameActors first, not sure what I was thinking xD also sorry again for not using the code boxes, but for some reason they're not working exactly right?(at least not on my end not sure if it's just me or.. ._.)

The code boxes aren't working for me either. For the partymember variable I just told it to subtract 1 just before I called it in the conditinal branch , and that fixed my problem.
kk, glad that worked out, but yeah, if you're only trying to get a specific actor, it's better to use $gameActor._data, rather than $gameParty.members(), they both return an actor, but $gameParty.members, will only get actors if they are in the party, and it will return them by the partys index, not the actor id, so if your party is something like this(using default actors).


Going from the top of the party list to the bottom
Lucius(actorID 4)
Harold(actorID 1)
Marsha(actorID 3)


Therese(actorID 2)


$gameParty.members()[0] would return Lucius


$gameParty.members()[1] would return Harold


$gameParty.members()[2] would return Marsha


$gameParty.members()[3] would return Therese


hopefully this makes sense ._.; apologies if not, maybe someone can explain it better, I've never been good at explaining things xD
kk, glad that worked out, but yeah, if you're only trying to get a specific actor, it's better to use $gameActor._data, rather than $gameParty.members(), they both return an actor, but $gameParty.members, will only get actors if they are in the party, and it will return them by the partys index, not the actor id, so if your party is something like this(using default actors).


Going from the top of the party list to the bottom
Lucius(actorID 4)
Harold(actorID 1)
Marsha(actorID 3)


Therese(actorID 2)


$gameParty.members()[0] would return Lucius


$gameParty.members()[1] would return Harold


$gameParty.members()[2] would return Marsha


$gameParty.members()[3] would return Therese


hopefully this makes sense ._.; apologies if not, maybe someone can explain it better, I've never been good at explaining things xD

Thanks, you've done a great job explaining this to me.


I think using party over actor would be better here because this is for a custom level up event and it's dependant on the partymembers in my team. So there should never be a point where I use this event on someone outside the party.

Original thread: https://forums.rpgmakerweb.com/threads/script-call-for-if-actor-does-not-have-skill.60455/