Learn skill condition JS code help please

silvestro673

Veteran
Veteran
Joined
Apr 6, 2014
Messages
53
Reaction score
3
First Language
english
Primarily Uses
Hello. I'm using yanfly's skill learn core. I have a skill that I don't want available for learning to the class, unless a specific weapon is equipped.


<Learn Require Eval>
value = false;
var wpn = $game_actorId(this).weaponId().value;
if (wpn === 7) value = true;
</Learn Require Eval>


I know this doesn't work. I'm having a lot of trouble gleaning info I understand out of the js section of MV's help.


what's the correct code? It needs to work for any actor in the class and equipped with the weapon.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
What is this?  If it's the actor, then something like this might work:


value = this.hasWeapon($dataWeapons[id])


where id is the weapon's id, with no leading zeros.
 

silvestro673

Veteran
Veteran
Joined
Apr 6, 2014
Messages
53
Reaction score
3
First Language
english
Primarily Uses
this = the actor you are checking the skills on.


with all my attempts including your code


value = this.hasWeapon($dataWeapons[id]) ;


I keep getting a "this" undefined error  while playtesting. menu>skills>actor    so before i even see the skill types with the learn skills option, I see the error.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Then 'this' must not be the actor you are checking the skills on.


What 'this' is and how it works would be entirely dependent on the plugin.  Does Yanfly state that you can use 'this' to refer to the current actor?


Edit: this is the Skill Learn window, not the actor at all.  Use the following:


value = this._actor.hasWeapon($dataWeapons[id])
 
Last edited by a moderator:

silvestro673

Veteran
Veteran
Joined
Apr 6, 2014
Messages
53
Reaction score
3
First Language
english
Primarily Uses
value = this._actor.hasWeapon($dataWeapons[id]);


works great Thankyou. if i wanted to do something similar such as check to see if its a particular actor. would it be:


value = this._actor.actorId(id); ?


tested. nope
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
this._actor.actorId() will give you the id of the actor you're currently looking at.  If you want to see if that's actor 7, you'd do this:


value = this._actor.actorId() === 7


actorId() doesn't accept a parameter - it's returning the id of the actor you're running it on.
 

silvestro673

Veteran
Veteran
Joined
Apr 6, 2014
Messages
53
Reaction score
3
First Language
english
Primarily Uses
thank you. both your answers were very fast and spot on. 
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top