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.

[Resolved]KH II HUD Undefined Method Error

Hey guys I have a problem with SephirothSpawn's KH II HUD v.1.0.

So I follow the intructions, insert MCLAB, insert script, change switch ID, and made the faces folder.
But whenever I run the game, (I have an event that autoruns the switch) it just crashes and gives this error:
error-2.png

Line 506 is:
Code:
self.contents.stretch_blt(Main_Face_Rect, bitmap, bitmap.rect)

Other custom scripts I have running, is:
f0tz!'s Pixelmovement
A custom menu
And a script that disables the title screen.
 

khmp

Sponsor

The bitmap object is nil. It isn't being initialized properly before the stretch_blt call. I'm guessing that you may not have initialized some variable or constant used in the method below.
Code:
  def self.face(actor)

    begin

      return RPG::Cache.load_bitmap(Face_Folder,

        actor.kh_face, actor.character_hue)

    rescue

      return RPG::Cache.load_bitmap(Face_Folder,

        actor.kh_face_base, actor.character_hue)

    end

  end
So make sure you have the constant Face_Folder is initialized to the proper directory location of the faces. Then make sure the suffixes that are attached to the face images, if you have one, in the Face_Folder dir has been initialized for the actor. Meaning if you have a suffix on the end of the filenames of the face images e.g:

actor1_kh.png
actor2_kh.png

Initialize each of your actor's kh_face_suffix instance variable to the proper string. Using the example above it would be _kh.
Code:
$game_actors[actor_id].kh_face_suffix = '_kh'
Hope that helps. If you still have trouble let us know.

Good luck with it kiralim! :thumb:
 
Ok I read your post several times, trying to understand it. And the result was that I understand that I didn't initialize that thing. So I changed line 504:
Code:
bitmap = Kingdom_Hearts_2_HUD.face(@actors[0])

to this:
Code:
bitmap = Kingdom_Hearts_2_HUD.face(@actors[1])

So I test run the game, I do not have the previouse error now, instead, I have this new error:
error2-1.png

Line 134 and 135 are:
Code:
return RPG::Cache.load_bitmap(Face_Folder, 

        actor.kh_face_base, actor.character_hue)
 

khmp

Sponsor

Alright my bad I'll try a different way. Main thing, these next few parts only concern you if you have suffix attached to your images.
ex: actorname_suffix.bmp

[kh_face_suffix]
What SephirothSpawn's code does in Game_Actor is just adds a piece of data called kh_face_suffix. What this guy does is automatically adds a string to the end of the actor's name whenever you go to grab the face image. Let's say your first actor is named "Carl". So you would have a picture in your face folder directory named "Carl.png". But if you have a suffix on the filename to specify it's a face picture like "_fp" you would have needed to initialize the kh_face_suffix for that actor to "_fp". With that suffix and name as an example, the filename would look like, "Carl_fp.png".
Code:
$game_actors[1].kh_face_suffix = '_fp'
And that initialization would have needed to occur before the picture is drawn on the screen otherwise you get an error. So somewhere you would iterate through your $game_actors and initialize their kh_face_suffix instance variable. This can be done any time after $game_actors is initialized in Scene_Title. Assuming they all share a similar suffix you could use something like the code below:
Code:
$game_actors.each { |actor| actor.kh_face_suffix = '_fp' }
This could also be done in an event before the HUD is displayed if you wanted. I didn't mean for you to change that line of code that you did.
[/kh_face_suffix]

The other thing that could be going wrong is that the constant called Face_Folder, which is somewhere near the top of SephirothSpawn's script, isn't pointing to the proper folder. So double check it and make sure.

Basic summary of my advice:
Make sure the constant Face_Folder is correct.
If your face images have a suffix make sure that actor's kh_face_suffix is initialized properly.

If you have any other questions or want me to clear something up let me know.
 
The constant for Face_folder would be this:
Code:
Face_Folder = 'Graphics/HUD Faces/'
correct?

If so, I checked it and it's correct. I have a HUD Faces folder in my Graphics folder. In it contains a Sora_face.png. And I still get the line 135 error.

Also, if I were to call the initializing through an event it would be this, right?:
Code:
$game_actors[1].kh_face_suffix = '_face'
 

khmp

Sponsor

Looks right give it a go. As long as that $game_actors[1].kh_face_suffix = '_face' occurs before the HUD is drawn. If not and you're still having problems. I recommend making a demo of your project and if you're worried about privacy just PM the link. It's become a mission now to solve the problem. :shades:

[edit] I am correcting myself after seeing it in a project just so I don't confuse someone else reading this topic having similar trouble. Firstly do not mess with the suffix thing as I tried to do above. This is used internally based off a constant hash object you mess around with. Second and more importantly the face image's filename should be the same name as the character graphic. Not the actor's name. The character_name is the filename of the image that represents an actor on the map. I have forgot so much shame on me :biggrin: But that is the gist of the issue encountered in this thread.
 
Kiralim, in the other scripts you are using you dont mention the MACL/SDK do you have both of these present in the project? Otherwise there may be some errors, just seemed like the most obvious reason the errors would be occuring as the script was flawless by default when I tried it in a blank project.
 

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