Mikuri 0 Report post Posted June 3, 2012 (edited) Hello, very weird request here. The answer must be very short, but I can't find it ¬¬ So, I want to display a simple list of skills + icons. It must be the a list containing all the hero (or class) skills that he can learn, even if he doesn't have it yet! In def refresh I have: @data = [] for i in 0...actor.skills.size skill = $data_skills[actor.skills[i]] if skill != nil @data.push(skill) end end @item_max = @data.size if @item_max > 0 for i in 0...@item_max draw_item(i) end end And obviously the def draw_item: def draw_item(index) skill = @data[index] x = 233 y = 132 + (index * 16) rect = Rect.new(x, y, self.width / 1 - 32, 32) bitmap = RPG::Cache.icon(skill.icon_name) self.contents.blt(x, y + 9, bitmap, Rect.new(0, 0, 34, 24), 255) self.contents.font.size = 14 self.contents.draw_text(x + 36, y, 204, 32, skill.name, 0) self.contents.font.size = 22 end Problem is, this ONLY shows skills that the actor learned and not every skills he can learn. (This is pretty much the same code as the skill menu by the way) How to access every skills the hero/class can learn? If off course, this is possible ^^'! Thank you ;o; Edited June 3, 2012 by Mikuri Share this post Link to post Share on other sites
Moonpearl 32 Report post Posted June 3, 2012 What you're looking for is in the RPG::Class#learnings variable (see RMXP's help for more info). Just access it and retrieve skills from it. # Iterate through classes for i in 0...$data_classes.size learnings = $data_classes[i].learnings # Iterate through skills class can learn for learning in learnings # Get level at which skill is learned and do whatever with it learning.level # Get skill from learning's skill id skill = $data_skills[learning.skill_id] end end 1 Mikuri reacted to this Share this post Link to post Share on other sites
Mikuri 0 Report post Posted June 3, 2012 Yay! I've looked in it but the infos on it are kinda limited and I didn't know how to use it. But this: "learnings = $data_classes.learnings" was exactly what I was looking for! Problem solved, a very big thank you for you sir <3 Share this post Link to post Share on other sites
Moonpearl 32 Report post Posted June 3, 2012 You're welcome, it was a matter of five minutes. Share this post Link to post Share on other sites
ForeverZer0 44 Report post Posted June 3, 2012 A simpler solution to simply get an array of skills able to be learned by an actor is this: klass = $data_classes[$data_actors[1].class_id] skills = klass.learnings.collect {|ln| $data_skills[ln.skill_id] } You have to replace the index for $data_actors with your actor's id, or simply use an instance of an actor instead of using $data_actors. ie. @actor Share this post Link to post Share on other sites
Moonpearl 32 Report post Posted June 3, 2012 (edited) Of course there are more elegant ways to express these, but I thought Mikuri might prefer a simple to understand solution with no complicated Ruby syntax. Edited June 3, 2012 by Moonpearl Share this post Link to post Share on other sites
Mikuri 0 Report post Posted June 3, 2012 Haha, yeah, there is always a "simplier, yet harder to read" code to do the same thing :P But I got it to work already with Moonpearl's help. Thanks for the second input thou! Learned me that there's still so many things I don't know in Ruby xD On a side note, I have another question, must be easy too for you guys ^^' What is the script which replace the event command "If hero x is in team"? I have many heros and I simply want to put a check next to the name in a list if it is in team. Thing is, there's heros in the $game_party.actors and in the $game_party.party_members. Must be an easier way to simply check if he joined the team with yes or no with the hero ID? Thanks :) Share this post Link to post Share on other sites
ForeverZer0 44 Report post Posted June 4, 2012 I don't really consider nested loops simpler than a single method call of Enumerable...but that's just me. "collect" is a common Ruby call that no one seems to use simply because it is not in found in RGSS, yet makes for a more efficient and simpler method of doing things. Here's a couple methods. The first uses an actor instance, the second an ID. Both return a boolean if actor is found or not. $game_party.actors.include?(@actor) $game_party.actors.find {|a| a.id == ID } != nil Share this post Link to post Share on other sites
kellessdee 48 Report post Posted June 4, 2012 You'll want to use $game_party.actors I am pretty sure "party_members" only exists for $data_system.party_members, which refers to an array of the initial party when the player starts the game. $game_party.actors is an Array of Game_Actor objects, so you have a few ways of checking if the actor is in the party. The way that the event command interpreter does this is: actor = $game_actors[ACTOR_ID] #get actor object $game_party.actors.include?(actor) include?(value) returns true, if the value is contained in the array, so you could do something like: if $game_party.actors.include?(actor) #actor is in party end or, if you wanna simply check against the actual ID number, without having to get the Game_Actor object: if $game_party.any? { |actor| actor.id == ACTOR_ID } #actor is in party end In both cases "ACTOR_ID" refers to whichever ID you want to check for. Hope this helps EDIT: ForeverZer0 beat me to it, lol Share this post Link to post Share on other sites
forcebreaker 0 Report post Posted June 4, 2012 Wow, Kellessdee....i dont know how you can contain all those numbers and formulas 0.0 !!! Share this post Link to post Share on other sites
Bob423 52 Report post Posted June 4, 2012 your brain has more memory space than your harddrive, force, its not surprising to me :P Share this post Link to post Share on other sites
Bigace360 38 Report post Posted June 4, 2012 Wow, Kellessdee....i dont know how you can contain all those numbers and formulas 0.0 !!! It's not that hard as long as you know what you're talking about. Share this post Link to post Share on other sites
forcebreaker 0 Report post Posted June 4, 2012 LOL! Maybe one day soon, ill learn to script as good as Kellessdee! Share this post Link to post Share on other sites
Mikuri 0 Report post Posted June 4, 2012 I love you guys <3 Works like a charm and my script is done! Thank you very much Share this post Link to post Share on other sites