Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Skill name and icon

I've done a custom window that shows the HP, SP and the player's name and I want to add a special feature:

I want to show: [ICON] Skill name wich ID in the database is 21.

This is the code for that custom window:

Code:
class GR_Window_HUD < Window_Base
#--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.z = 255
    self.contents.font.size = 16
    @actor = $game_party.actors[0]
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.bold = true
    draw_actor_name(@actor, 408, 0)
    draw_actor_hpEX(@actor, 390, 17)
    draw_actor_spEX(@actor, 406, 34)
    self.contents.font.bold = false
  end
  #--------------------------------------------------------------------------
  # * Draw Skill
  #     index : database skill index number
  #--------------------------------------------------------------------------
  def draw_skill(index)
    skill = $data_skills(index) # or (21) don't works
    x = 400
    y = 64

    bitmap = RPG::Cache.icon(skill.icon_name)# this is supposed to draw the skill icon but the game crashes
  
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  end
end
It's supposed to go here:

http://i17.photobucket.com/albums/b76/G ... helpme.png[/IMG]

I don't know waht to do, I tried to learn something reading the Window_Skill, Scene_Skill and the Game_Actor classes but can't do anything.
 
Posting the error message you got would ease it to help you... until then, I suppose the only problem is that the variable 'skill' is undefined... define it somewhat like this...
Code:
skill = $data_skills(index)
This code piece should be directly above 'x = 400'
 
He mistyped it ^^
Code:
skill = $data_skills[index]

Also,
Code:
skill_name = skill.name
skill_icon = skill.icon_name
... If i´m not wrong...

EDIT: Yes, that´s it. Just correct the mistake *in draw_skill* and be sure to call it somewhere.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top