RPG Maker Forums

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?

 

#===== 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 :p

#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::pARTY::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::pARTY::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::pARTY::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

@box_icon=@actor.box_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!

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,837
Latest member
Dabi
Top