Moghunter's Battle HUD and Victor SFonts issue

Status
Not open for further replies.

don'taskme

Villager
Member
Joined
Jul 12, 2015
Messages
12
Reaction score
1
First Language
English
Primarily Uses
So, I have an issue with Moghunter's Battle HUD script and with Victor's SFonts.

I needed to make the character's name uses the SFont too.

I found this thread that managed to solve the solution.
https://forums.rpgmakerweb.com/index.php?threads/victor-sfonts-as-default-font.81420/

However, I'm unsure of what are the arguments used for Victor's SFont script.

This is the method to draw the text using SFont, I assume.
Code:
def draw_sfont_text(*args)
    is_rect = args[0].is_a?(Rect)
    x      = is_rect ? args[0].x      : args[0]
    y      = is_rect ? args[0].y      : args[1]
    width  = is_rect ? args[0].width  : args[2]
    height = is_rect ? args[0].height : args[3]
    text   = is_rect ? args[1].to_s   : args[4].to_s
    align  = is_rect ? args[2]        : args[5]
    bitmap = sfont.draw_text(text)
    x += width - bitmap.width       if align == 2
    x += (width - bitmap.width) / 2 if align == 1
    y += (height - bitmap.height) / 2 - 4
    blt(x, y, bitmap, bitmap.rect)
  end
This is Moghunter's original method to draw the name.
Code:
@name.bitmap.draw_text(0,0,160,32,@actor.name,NAME_ALIGN_TYPE)
And lastly, my failed method so far to draw the name text using SFonts.
Code:
@name.bitmap.draw_sfont_text(0,0,160,32,@actor_name,0)
This is the error that occurs when I started the battle test.
upload_2019-3-11_1-30-44.png

Line 201 gives me this:
Code:
bitmap = sfont.draw_text(text)
Would anyone give me a pointer on what I did wrong?
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,867
Reaction score
5,240
First Language
Dutch
Primarily Uses
RMXP

Since you need help with existing scripts, I've moved this to Script Support.

 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
It's missing that sfont variable for some reason.
Try to set the VE_ALL_SFONT setting to true, that should make all windows use the sfont drawing method.

If for some reason you don't want all windows to use the sfont drawing method, you will have to manually create that variable for the window you are working in.
You can do so by using this line:
Code:
contents.sfont = $sfont[0]
You have to place this in the window's create_contents method, after the original parts. Something like this:
Code:
  def create_contents
    super
    contents.sfont = $sfont[0] # This will make that missing variable.
  end
If the window got no such method defined yet, just add the above code anywhere into the window class.
If the window already has that method defined, you can either add in the marked line directly there from above, or alias the method and add the line that way.
Ohh, and this all assumes that Moghunter's script draws those names on windows and not on sprites (on their bitmap, more specifically) directly. If they are drawn on sprites, you will have to replace the contents part of that code line with self.bitmap, and you will have to add that line somewhere where the bitmap is already set up.

For the record, your draw_sfont_text method is correct, you don't have to change anything there.
 

don'taskme

Villager
Member
Joined
Jul 12, 2015
Messages
12
Reaction score
1
First Language
English
Primarily Uses
Alright, I followed your advice, and what do you know.
It actually worked!
Thanks so much for the help.
Mods, you can close the thread now.
upload_2019-3-14_17-36-0.png
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,867
Reaction score
5,240
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,454
Members
137,821
Latest member
Capterson
Top