One of my script i use draws bars and displays numbers when changing party members. The only problem is, when a character reaches the final level (the highest level they can get to), the EXP bar turns into ---/--- and my script doesnt know what to do about that.
Heres the part of teh script im havin trouble with:
def draw_bar(x, y, min, max, width = 152, height = 20)
self.contents.fill_rect(x, y, width, height, Color.new(255, 255, 255, 100))
bar_color = Color.new(0, 0, 200, 255)
for i in 0..(width * min / max)
r = bar_color.red * (width - i) / width + 0 * i / width
g = bar_color.green * (width - i) / width + 0 * i / width
b = bar_color.blue * (width - i) / width + 0 * i / width
a = bar_color.alpha * (width - i) / width + 255 * i / width
self.contents.fill_rect(x + i, y, 1 , height, Color.new(r, g, b, a))
end
end
EDIT: Also, theres a draw information area that i didnt notice XD
Here it is
#--------------------------------------------------------------------------
# Draws Information
#--------------------------------------------------------------------------
def draw_info
contents.clear
# Draws actors
for i in 0...@actors.size
actor = @actors
y = i * 64 + 8
if actor == nil
contents.font.size = 40
contents.font.color = disabled_color
contents.draw_text(60, y - 8, contents.width, 64, "Empty Position")
else
contents.font.size = 22
# Draws Name
contents.font.color = normal_color
contents.draw_text(60, y, 90, 24, actor.name)
# Draws Class
contents.draw_text(60, y + 24, 90, 24, $data_classes[actor.class_id].name)
# Draws Level
contents.font.color = system_color
contents.draw_text(160, y, 100, 24, "Level")
contents.font.color = normal_color
contents.draw_text(160, y, 100, 24, actor.level.to_s, 2)
# Draws State
state = make_battler_state_text(actor, 112, true)
contents.font.color = actor.hp == 0 ? knockout_color : normal_color
contents.draw_text(160, y + 24, 100, 24, state)
# Draws Experience
contents.font.color = system_color
contents.draw_text(274, y, 160, 24, "Exp")
contents.font.color = normal_color
contents.draw_text(274, y, 160, 24, actor.exp.to_s, 2)
# Draws Next Level Bar
draw_bar(270, y + 26, actor.exp, actor.next_exp_s.to_i, 168)
# Draws Next Level
contents.font.color = system_color
contents.draw_text(274, y + 24, 160, 24, "Next Level")
contents.font.color = normal_color
contents.draw_text(274, y + 24, 160, 24, actor.next_rest_exp_s.to_s, 2)
# Draw HP Bar
draw_bar(446, y + 2, actor.hp, actor.maxhp)
# Draw MP Bar
draw_bar(446, y + 26, actor.sp, actor.maxsp)
# Draws HP
contents.font.size = 22
contents.font.color = system_color
contents.draw_text(452, y, 160, 24, $data_system.words.hp)
contents.font.size = 16
contents.font.color = actor.hp == 0 ? knockout_color : normal_color
contents.draw_text(452, y, 140, 24, "#{actor.hp} / #{actor.maxhp}", 2)
# Draws SP
contents.font.size = 22
contents.font.color = system_color
contents.draw_text(452, y + 24, 160, 24, $data_system.words.sp)
contents.font.size = 16
contents.font.color = actor.sp == 0 ? knockout_color : normal_color
contents.draw_text(452, y + 24, 140, 24, "#{actor.sp} / #{actor.maxsp}", 2)
end
end
end
could someone edit this as to when a character reaches max level, the bar will stay at 100%?
thx for the help!
Heres the part of teh script im havin trouble with:
def draw_bar(x, y, min, max, width = 152, height = 20)
self.contents.fill_rect(x, y, width, height, Color.new(255, 255, 255, 100))
bar_color = Color.new(0, 0, 200, 255)
for i in 0..(width * min / max)
r = bar_color.red * (width - i) / width + 0 * i / width
g = bar_color.green * (width - i) / width + 0 * i / width
b = bar_color.blue * (width - i) / width + 0 * i / width
a = bar_color.alpha * (width - i) / width + 255 * i / width
self.contents.fill_rect(x + i, y, 1 , height, Color.new(r, g, b, a))
end
end
EDIT: Also, theres a draw information area that i didnt notice XD
Here it is
#--------------------------------------------------------------------------
# Draws Information
#--------------------------------------------------------------------------
def draw_info
contents.clear
# Draws actors
for i in 0...@actors.size
actor = @actors
y = i * 64 + 8
if actor == nil
contents.font.size = 40
contents.font.color = disabled_color
contents.draw_text(60, y - 8, contents.width, 64, "Empty Position")
else
contents.font.size = 22
# Draws Name
contents.font.color = normal_color
contents.draw_text(60, y, 90, 24, actor.name)
# Draws Class
contents.draw_text(60, y + 24, 90, 24, $data_classes[actor.class_id].name)
# Draws Level
contents.font.color = system_color
contents.draw_text(160, y, 100, 24, "Level")
contents.font.color = normal_color
contents.draw_text(160, y, 100, 24, actor.level.to_s, 2)
# Draws State
state = make_battler_state_text(actor, 112, true)
contents.font.color = actor.hp == 0 ? knockout_color : normal_color
contents.draw_text(160, y + 24, 100, 24, state)
# Draws Experience
contents.font.color = system_color
contents.draw_text(274, y, 160, 24, "Exp")
contents.font.color = normal_color
contents.draw_text(274, y, 160, 24, actor.exp.to_s, 2)
# Draws Next Level Bar
draw_bar(270, y + 26, actor.exp, actor.next_exp_s.to_i, 168)
# Draws Next Level
contents.font.color = system_color
contents.draw_text(274, y + 24, 160, 24, "Next Level")
contents.font.color = normal_color
contents.draw_text(274, y + 24, 160, 24, actor.next_rest_exp_s.to_s, 2)
# Draw HP Bar
draw_bar(446, y + 2, actor.hp, actor.maxhp)
# Draw MP Bar
draw_bar(446, y + 26, actor.sp, actor.maxsp)
# Draws HP
contents.font.size = 22
contents.font.color = system_color
contents.draw_text(452, y, 160, 24, $data_system.words.hp)
contents.font.size = 16
contents.font.color = actor.hp == 0 ? knockout_color : normal_color
contents.draw_text(452, y, 140, 24, "#{actor.hp} / #{actor.maxhp}", 2)
# Draws SP
contents.font.size = 22
contents.font.color = system_color
contents.draw_text(452, y + 24, 160, 24, $data_system.words.sp)
contents.font.size = 16
contents.font.color = actor.sp == 0 ? knockout_color : normal_color
contents.draw_text(452, y + 24, 140, 24, "#{actor.sp} / #{actor.maxsp}", 2)
end
end
end
could someone edit this as to when a character reaches max level, the bar will stay at 100%?
thx for the help!