The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: munkis on July 23, 2013, 08:34:16 PM

Title: [RMVX] Bit of a problem with a script I'm working on...
Post by: munkis on July 23, 2013, 08:34:16 PM
I'm working on a custom ABS HUD, and I'm having a problem that I can't quite figure out.  I have it so that the script will only draw the icons of the items you actually have (the IDs can be changed from inside a config module).  What I can't figure out is how to do the same thing with the skills; the closest I've been able to come is drawing all of the icons for the skill IDs in the config module:

Item Icons:

class Hud_Item_Bar_Icons < Window_Base
  def initialize
    super(312, 357, 160, 100)
    self.opacity = 0
    self.z = 16
  end
  def update
    contents.clear
    draw_icon($data_items[MNK_ABS_HUD::ITEM_IDS[0]].icon_index, 0, 0) unless $game_party.item_number($data_items[MNK_ABS_HUD::ITEM_IDS[0]]) == 0
    draw_icon($data_items[MNK_ABS_HUD::ITEM_IDS[1]].icon_index, 24, 0) unless $game_party.item_number($data_items[MNK_ABS_HUD::ITEM_IDS[1]]) == 0
    draw_icon($data_items[MNK_ABS_HUD::ITEM_IDS[2]].icon_index, 48, 0) unless $game_party.item_number($data_items[MNK_ABS_HUD::ITEM_IDS[2]]) == 0
    draw_icon($data_items[MNK_ABS_HUD::ITEM_IDS[3]].icon_index, 72, 0) unless $game_party.item_number($data_items[MNK_ABS_HUD::ITEM_IDS[3]]) == 0
    draw_icon($data_items[MNK_ABS_HUD::ITEM_IDS[4]].icon_index, 96, 0) unless $game_party.item_number($data_items[MNK_ABS_HUD::ITEM_IDS[4]]) == 0
  end
end


Skill Icons:

class Hud_Skill_Bar_Icons < Window_Base
  def initialize
    super(312, 407, 160, 100)
    self.opacity = 0
    self.z = 16
  end
  def update
    contents.clear
    draw_icon($data_skills[MNK_ABS_HUD::SKILL_IDS[0]].icon_index, 0, 0)
    draw_icon($data_skills[MNK_ABS_HUD::SKILL_IDS[1]].icon_index, 24, 0)
    draw_icon($data_skills[MNK_ABS_HUD::SKILL_IDS[2]].icon_index, 48, 0)
    draw_icon($data_skills[MNK_ABS_HUD::SKILL_IDS[3]].icon_index, 72, 0)
    draw_icon($data_skills[MNK_ABS_HUD::SKILL_IDS[4]].icon_index, 96, 0)
  end
end


What am I missing?
Title: Re: [RMVX] Bit of a problem with a script I'm working on...
Post by: modern algebra on July 23, 2013, 09:00:18 PM
Well, for your condition, you just need to check if the actor has learned the skill. Assuming it is the first actor, it would be:



    draw_icon($data_skills[MNK_ABS_HUD::SKILL_IDS[0]].icon_index, 0, 0) if $game_actors[1].skill_learn?($data_skills[MNK_ABS_HUD::SKILL_IDS[0]])


Just replace the 1 with the ID of the actor. Alternately, you could use lead actor with:


$game_party.members[0].skill_learn?($data_skills[MNK_ABS_HUD::SKILL_IDS[0]])


However, you might want to do a check to make sure that $game_party.members isn't empty first, as there could be situations in the game where the creator takes all members out of the party (for a cutscene or something), and if that check is conducted at that time then it would return a NoMethod Error.


EDIT::

Sorry, I had originally kept "unless". It should be "if".