What's the snippet for checking if a certain skill is learned

RoseofCrimson

Veteran
Veteran
Joined
Oct 14, 2015
Messages
125
Reaction score
43
First Language
English
$game_party.actors[@actor].skill_learn?(skillid) or skill_include?

I'm trying to write a script that checks to see if the first member of the party knows x skill (let's say the first skill in the database).

I'd also like to know the snippet for $game_actors[1] etc etc.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,253
Reaction score
1,254
First Language
Spanish
Primarily Uses
RMVXA
actor.skill_learn?(skill)
skill *object*, not ID
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,253
Reaction score
1,254
First Language
Spanish
Primarily Uses
RMVXA
$game_actors[1].skill_learn?($data_skills[9])
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@gstv87 Just checking - is that bit of code in RGSS? It looks like RGSS3, though of course I could be wrong.
 

RoseofCrimson

Veteran
Veteran
Joined
Oct 14, 2015
Messages
125
Reaction score
43
First Language
English
It's was RGSS the solution was as simple as removing the
$data_skills[9]
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,253
Reaction score
1,254
First Language
Spanish
Primarily Uses
RMVXA
@Kes
the syntax is what I posted first: actor.skill_learn?(skill)
actor and skill being both objects, regardless of language or data structure.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,269
Reaction score
1,423
First Language
English
Primarily Uses
RMXP
From the Game_Actor section in the script editor we can peruse the relevant code:
Code:
  #--------------------------------------------------------------------------
  # * Learn Skill
  #     skill_id : skill ID
  #--------------------------------------------------------------------------
  def learn_skill(skill_id)
    if skill_id > 0 and not skill_learn?(skill_id)
      @skills.push(skill_id)
      @skills.sort!
    end
  end
  (...)
  #--------------------------------------------------------------------------
  # * Determine if Finished Learning Skill
  #     skill_id : skill ID
  #--------------------------------------------------------------------------
  def skill_learn?(skill_id)
    return @skills.include?(skill_id)
  end
From this we can determine that skill_id should be a number. For example you can do something like this.
Code:
# Let us check if the first party member has learned the skill with id 9 in the database
$game_party.actors[0].skill_learn?(9)

# If you are using this in a script call you may have to split it up over multiple lines
actor = $game_party.actors[0]
if actor.skill_learn?(9)
  p "Do stuff here"
end

# Remember not to include leading zeroes.
$game_party.actors[0].skill_learn?(09) # Wrong
Good luck with your script

*hugs*
- Zeriab
 

RoseofCrimson

Veteran
Veteran
Joined
Oct 14, 2015
Messages
125
Reaction score
43
First Language
English
I figured it out a few hours prior, but thanks for the in depth explanation, Z'. I'm sure it'll help in similar problems in the future.
 

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

Latest Threads

Latest Profile Posts

Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect
I have gathered enough feedback from a few selected people. But it is still available if you want to sign up https://forums.rpgmakerweb.com/index.php?threads/looking-for-testers-a-closed-tech-demo.130774/

Forum statistics

Threads
105,992
Messages
1,018,189
Members
137,771
Latest member
evoque
Top