[ACE] Help with HUD script and Yanfly's save engine

Hello people! I got two more questions!

First and foremost; I want to have an onscreen HUD that displays actors hp, level and exp, so I found lilcooldude69's Simple Hud and made some adjustments to it and it works great with an already made save! But if I start a new game it gives "HUD:101:  in 'draw_window_content' : undefined method 'level' for nil:NilClass <NoMethodError>. I worked on it for hours but I can't find a solution (I don't have much understanding of Ruby, but I can sometimes understand stuff). What should I do to make it work in New Games too?

 

Spoiler
#===== Rpg Makver VX ACE Script =============================

#= Simple Hud

#===== By: ==================================================

#= lilcooldude69

#===== Current Version: =====================================

#= 1.0

#===== Compatible With: =====================================

#= Rpg Maker VX ACE

#===== Description: =========================================

#= Sells items useful for 2-2 Classes

#===== Additional Comments: =================================

#=

#============================================================

 

module Hud_config

#Configuration

SWITCH = 13 #the number of the switched used to make it visible Example: if this is 1 then Switch 001 will turn on the hud.

EXPTERM = "Exp" #Term used for The Exp Bar

OPACITY = 70 #used for the opacity of the window, Mess with this to your liking 😛

#end config

end

#=====DO NOT EDIT PAST HERE UNLESS YOU KNOW WHAT YOUR DOING======#

#=================EXCLUDING WHAT WAS SAID ABOVE==================#

include Hud_config

module Cache

#--------------------------------------------------------------------------

# * Get Icon Graphic

#--------------------------------------------------------------------------

def self.box_icon(filename)

load_bitmap("Graphics/#{CRYSTAL:😛ARTY::ICON_FOLDER}/", filename)

end

end

#=====

class Game_Battler < Game_BattlerBase

#--------------------------------------------------------------------------

# * Icon in the Box

#--------------------------------------------------------------------------

def box_icon

if $imported["CE-Daycare&Egg"] && egg?

folder = "Graphics/#{CRYSTAL:😛ARTY::ICON_FOLDER}/"

c = sprintf("icon%3.3dEgg", self.class.id)

if FileTest.exists?("#{folder}#{c}.png")

return c

else

return "iconEgg"

end

else

folder = "Graphics/#{CRYSTAL:😛ARTY::ICON_FOLDER}/"

c = sprintf("icon%3.3d%s", self.class.id, @form == 0 ? "" : "_#{@form}")

if FileTest.exists?("#{folder}#{c}.png")

return c

else

c = sprintf("icon%3.3d", self.class.id,)

if FileTest.exists?("#{folder}#{c}.png")

return c

else

raise SyntaxError.new(sprintf("The class %s does not have an icon file for

it. Please make sure that you make one for it. Refer to Crystal Engine - 

Party Menu for naming infromation.", self.class.name))

end

end

end

end

end

class Window_Base < Window

#--------------------------------------------------------------------------

# * Draw Icon Graphic

#--------------------------------------------------------------------------

def draw_poke_icon(icon_name, x, y)

bitmap = Cache.box_icon(icon_name)

rect = Rect.new(0, 0, 64, 64)

contents.blt(x, y, bitmap, rect)

bitmap.dispose

end

end

class Window_Hud < Window_Base

#----------------------------------------------------

# * Object Initialization

#----------------------------------------------------

def initialize

super(0,0, 125,125)

create_contents

self.visible = $game_switches[sWITCH]

@actor = $game_party.members[0]

refresh

end

def exp_gauge_color1; text_color(31); end;

def exp_gauge_color2; text_color(27); end;

#----------------------------------------------------

# * Refresh

#----------------------------------------------------

def refresh

self.contents.clear

contents.clear

draw_window_content

end

#----------------------------------------------------

# * Draw Window Contents * Drawing of all the contents gold, hp bar, etc

#----------------------------------------------------

def draw_window_content

@level = @actor.level

@hp = @actor.hp

@exp = @actor.exp

@[email protected]_icon

draw_poke_icon(@actor.box_icon, 0, 0)

contents.font.size = 20

draw_actor_name(@actor, 0, 0)

draw_actor_level(@actor, 45, 0)

draw_actor_hp(@actor, 0, 17, 48)

draw_exp(@actor, 0, 60, 102)

end

#-----------------------------------------------------

# * Update * used to keep things up to date

#-----------------------------------------------------

def update

super

self.visible = $game_switches[sWITCH]

return if !self.visible

if @level != @actor.level or @hp != @actor.hp or @exp != @actor.exp

refresh

end

end

#-----------------------------------------------------

# * Custom Definition for the experience bar free to use if you like

#-----------------------------------------------------

def draw_exp(poke, x, y, width = 124)

now_exp = poke.exp - poke.current_level_exp

next_exp = poke.next_level_exp - poke.current_level_exp

rate = now_exp * 1.0 / next_exp

fill_w = (width * rate).to_i

gauge_y = y + line_height - 8

contents.fill_rect(x, gauge_y, width, 6, Color.new(255,255,255))

contents.gradient_fill_rect(x, gauge_y, fill_w, 6, Color.new(24,144,248), Color.new(24,144,248))

change_color(system_color)

draw_text(x, y, 30, line_height, EXPTERM)

change_color(text_color(27))

if poke.max_level? ? draw_text(x + width - 72, y, 72, line_height, "------------", 2)

:

draw_text(x + width - 72, y, 72, line_height, poke.next_level_exp.to_i - poke.exp.to_i, 2)

end

end

end

#return if actor.max_level?

 

 

#------------------------------------------------------

# * Scene_Map Class, For keeping it on the map

#------------------------------------------------------

class Scene_Map < Scene_Base

alias start_window start

alias term_window terminate

alias update_window update

def start

start_window

@winhud = Window_Hud.new

update

end

def terminate

@winhud.dispose

term_window

end

def update

update_window

@winhud.update

end

end
 

Second and last; I use Yanfly's Ace Save Engine, and it works great thoug when I allow multiple save files and choose a save file the cursors stays there so I have to press left to get the cursor on Load Save Delete menu. Why is that?

Thanks in advance!
Don't know about the second.

But for the first, I'm going to take a guess and say that it's because you're beginning the game with no party members (while you obviously have at least one party member in the save files). Whoever made that script was careless and assumed that the player will always start the game with at least one party member and hard-baked that into the script. You'll either have to learn scripting and modify the script yourself (which will probably end up with you rewriting a good portion of the script, which sounds hard but is really not because it is such a small script), or find a new GUI script or work around it and make sure you start the game with at least one party member.

Oh, and not to mention, this script also doesn't change the actor it shows until you leave the map (to enter a battle or a menu) and come back, so if you switch order of party members through events, that HUD will still show the same actor.

I always advocate learning to script (or at least enough to make the modification) but if you don't have the time or really can't be bothered I would just pick up another GUI script. There are just so many, I don't think you'll have much trouble finding a new one. Your choice if you want to work around it, but preserving basic functionality (i.e. being able to start the game with no members) always takes priority in my opinion.
I may have gotten the script to there actually (hard baking part member requirement) with my little knowledge 😀

But the last time I checked it was updating when I change the order. I'm on the learning to script train too, but don't have much free time for it. Thanks for the advice!
I doubt you're responsible, not if it's the same script as it is on here: http://forums.rpgmakerweb.com/index.php?/topic/1057-very-simple-hud/

The script was just... not made very well. Try removing all your party members with an event on the map, without entering the menu. The HUD won't change.

Original thread: https://forums.rpgmakerweb.com/threads/ace-help-with-hud-script-and-yanflys-save-engine.31798/