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.

Little bug at Caesar Questlog.

Hello guys. Im needing your help again, but this is a little bug we're talking about.
Im using Caesar Questlog script, which is is made of 2 scripts. Im posting them right now for people to see below:
Problem is this: If im about to add a new quest with the command:

Questlog.add("<icon=scroll> Solving my problem",
"Help Nebukadnezar II solving his problem
<br><image=questimage1><down=8><space=20>
<br>Place: Hbgames.org
<br>Reward: Much love
")

everything works fine. But when Im about to add a new quest, the Icon of the second quest stacks with the first one. What I mean is this: I have prepared a picture. Look exactly. If I have one quests, it looks fine. But when another quest is added, the icons stacks with the first one, wich it shouldnt be. I hope you understood me.
warawara.png


Code:
#///////////////////////HTML-Rendering-Engine/////////////////////////////////

#~~~~~~~~~~~~~~~~by Caesar~~~~~~~~~~~~~~~~~~~

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

class Bitmap

def draw_shadow_text(x, y, width, height, str, align=0)

color = font.color.dup

font.color = Color.new(192, 192, 192, 156)

draw_text(x+2, y+2, width, height, str, align)

font.color = color

draw_text(x, y, width, height, str, align)

end

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

def draw_html(x, y, width, height, str)

# remember string and font variables

str = str.dup

color = font.color.dup

bold = font.bold

italic = font.italic

size = font.size

name = font.name.dup

#::::::::::

shadow = false

underlined = false

opacity = 255

str.gsub!(/<if=([0-9]+)>(.+?)<else>(.+?)<\/if>/) {$game_switches[$1.to_i] ? $2 : $3}

str.gsub!(/<var=([0-9]+)>/) {$game_variables[$1.to_i].to_s}

str.gsub!(/<eval={(.+?)}>/) {eval $1}

str.gsub!(/<style=([A-Za-z0-9_-]+)>(.+?)<\/style>/) {

STYLES.has_key?($1) ? STYLES[$1].sub("|", $2) : ""

} if defined?(STYLES)

str.gsub!(/<br>/) {"\n"}

str.gsub!(/\\\\/) {"\00"}

str.gsub!(/<b>/) {"\01"}

str.gsub!(/<\/b>/) {"\02"}

str.gsub!(/<i>/) {"\03"}

str.gsub!(/<\/i>/) {"\04"}

str.gsub!(/<color=(#?[0-9a-z_]+)>/) {"\05[#{$1}]"}

str.gsub!(/<\/color>/) {"\06"}

str.gsub!(/<shadow>/) {"\16"}

str.gsub!(/<\/shadow>/) {"\17"}

str.gsub!(/<small>/) {"\20"}

str.gsub!(/<\/small>/) {"\21"}

str.gsub!(/<big>/) {"\23"}

str.gsub!(/<\/big>/) {"\21"}

str.gsub!(/<size=([0-9]+)>/) {"\24[#{$1}]"}

str.gsub!(/<\/size>/) {"\21"}

str.gsub!(/<font=([A-Za-z0-9\s]+)>/) {"\25[#{$1}]"}

str.gsub!(/<\/font>/) {"\26"}

str.gsub!(/<u>/) {"\27"}

str.gsub!(/<\/u>/) {"\30"}

str.gsub!(/<icon=([_A-Za-z0-9-]+)>/) {"\11[#{$1}]"}

str.gsub!(/<image=([_A-Za-z0-9-]+)>/) {"\31[#{$1}]"}

str.gsub!(/<down=([0-9]+)>/) {"\22[#{$1}]"}

str.gsub!(/<space=([0-9]+)>/) {"\100[#{$1}]"}

str.gsub!(/<line>/) {"\07"}

ix = 0

iy = 0

while ((c = str.slice!(/./m)) != nil)

if c == "\00" # \\

c = "\\"

end

if c == "\01" # <b>

font.bold = true

end

if c == "\02" #</b>

font.bold = bold

end

if c == "\03" # <i>

font.italic = true

end

if c == "\04" # </i>

font.italic = false

end

if c == "\05" # <color=xxx>

str.sub!(/\[(#?[0-9a-z_]+)\]/, "")

if $1[0] == 35

col = Color.decode($1)

elsif $1.to_i != 0

col = Window_Base.text_color($1.to_i)

else

col = Color.get($1)

end

font.color = col

end

if c == "\06" # </color>

font.color = color

end

if c == "\16" # <shadow>

shadow = true

end

if c == "\17" # </shadow>

shadow = false

end

if c == "\20" # <small>

font.size -= 5 if font.size > 10

end

if c == "\21" # </small> </big> </size>

font.size = size

end

if c == "\23" # <big>

font.size += 5 if font.size < 92

end

if c == "\24" # <size=xx>

str.sub!(/\[([0-9]+)\]/, "")

newsize = $1.to_i

font.size = newsize if newsize > 5 and newsize < 97

end

if c == "\25" # <font=xxx>

str.sub!(/\[([A-Za-z0-9\s]+)\]/, "")

font.name = $1 if Font.exist?($1)

end

if c == "\26" # </font>

font.name = name

end

if c == "\27" # <u>

underlined = true

end

if c == "\30" # </u>

underlined = false

end

if c == "\11" #<icon=xxx>

str.sub!(/\[([_A-Za-z0-9-]+)\]/, "")

icon = RPG::Cache.icon($1)

blt(ix + 8, iy + LINE_HEIGHT/2 - 12, icon, Rect.new(0, 0, 24, 24))

ix += 24

end

if c == "\31" # <image=xxx>

str.sub!(/\[([_A-Za-z0-9-]+)\]/, "")

image = RPG::Cache.picture($1)

iy += LINE_HEIGHT

blt((width-image.rect.width)/2, iy, image, image.rect)

iy += image.rect.height

ix = 0

end

if c == "\22" # <down=xxx>

str.sub!(/\[([0-9]+)\]/, "")

iy += $1.to_i

ix = 0

end

if c == "\100" # <space=xxx>

str.sub!(/\[([0-9]+)\]/, "")

ix += $1.to_i

c = ""

end

if c == "\07" # <line>

iy += LINE_HEIGHT + 3

fill_rect(16, iy, width-32, 2, font.color)

fill_rect(16, iy, width-32, 2, Color.new(192, 192, 192, 156)) if shadow

iy += 5

ix = 0

end

if c == "\n"

iy += LINE_HEIGHT

ix = 0

end

#:::::::::

if shadow

draw_shadow_text(x+ix+4, y+iy, 40, font.size, c)

else

draw_text(x+ix+4, y+iy, 40, font.size, c)

end

w = text_size(c).width

if underlined

fill_rect(x+ix+4, y+iy+text_size("T").height+3, w, 2, font.color)

end

ix += w

end

#::::::::::

#reset font variables

font.color = color

font.bold = bold

font.italic = italic

font.size = size

font.name = name

#return height of the bitmap

return iy + LINE_HEIGHT

end

end

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

class Color

def Color.get(s)

eval "Color.#{s}" rescue Color.white

end

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

def Color.decode(hex)

return Color.decode(hex[1..hex.length]) if hex[0] == 35

hex.downcase!

red = hex[0..1].hex

green = hex[2..3].hex

blue = hex[4..5].hex

alpha = hex.length == 8 ? hex[6..7].hex : 255

return Color.new(red, green, blue, alpha)

end

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

def Color.normal_color

return Color.new(255, 255, 255, 255)

end

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

def Color.disabled_color

return Color.new(255, 255, 255, 128)

end

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

def Color.system_color

return Color.new(192, 224, 255, 255)

end

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

def Color.crisis_color

return Color.new(255, 255, 64, 255)

end

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

def Color.knockout_color

return Color.new(255, 64, 0)

end

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

def Color.white(alpha=255)

return Color.new(255, 255, 255, alpha)

end

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

def Color.black(alpha=255)

return Color.new(0, 0, 0, alpha)

end

#----------

def Color.red(alpha=255)

return Color.new(255, 0, 0, alpha)

end

#----------

def Color.green(alpha=255)

return Color.new(0, 255, 0, alpha)

end

#---------

def Color.blue(alpha=255)

return Color.new(0, 0, 255, alpha)

end

#----------

def Color.yellow(alpha=255)

return Color.new(255, 255, 0, alpha)

end

#----------

def Color.cyan(alpha=255)

return Color.new(0, 255, 255, alpha)

end

#----------

def Color.magenta(alpha=255)

return Color.new(255, 255, 0, alpha)

end

#----------

def Color.light_gray(alpha=255)

return Color.new(192, 192, 192, alpha)

end

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

def Color.gray(alpha=255)

return Color.new(128, 128, 128, alpha)

end

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

def Color.dark_gray(alpha=255)

return Color.new(64, 64, 64, alpha)

end

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

def Color.pink(alpha=255)

return Color.new(255, 175, 175, alpha)

end

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

def Color.orange(alpha=255)

return Color.new(255, 200, 0, alpha)

end

end

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

class Window_Base < Window

# redefine text colors for static context

def self.text_color(n)

case n

when 0

return Color.new(255, 255, 255, 255)

when 1

return Color.new(128, 128, 255, 255)

when 2

return Color.new(255, 128, 128, 255)

when 3

return Color.new(128, 255, 128, 255)

when 4

return Color.new(128, 255, 255, 255)

when 5

return Color.new(255, 128, 255, 255)

when 6

return Color.new(255, 255, 128, 255)

when 7

return Color.new(192, 192, 192, 255)

else

return Color.white

end

end

end


Code:
#//////////////////////////////////Questlog 3.0/////////////////////////////////

#~~~~~~~~~~~~~~~~~~by Caesar~~~~~~~~~~~~~~~~~

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

#===================Parameter==================

# Wenn true, werden neue Quests oben eingefügt, ansonsten unten

INSERT_AT_TOP = true

# Zeilenhöhe in der Questbeschreibung

LINE_HEIGHT = 24

# Windowskin der Questlog-Fenster (nil = default)

WINDOWSKIN = nil

# "Überschrift" des Questlogs

HEADER_TEXT = "Questlog"

# Geschwindigkeit beim Scrollen (Pixel / Frame)

SCROLL_SPEED = 7

# Styles für die Beschreibungen der Quests

STYLES = {

"h1" => "<size=45><font=Cambria><b>|</b></font></size><down=40>",

"h2" => "<big><b><font=Cambria>|</font></b></big><down=32>",

"disabled" => "<color=disabled_color>|</color>",

"highlight" => "<color=#eeee32>|</color>",

"system" => "<color=system_color>|</color>"

}

# Dieser Process wird ausgeführt, sobald das Questlog geschlossen wird;

# (Default: Spieler kommt wieder auf die Map)

ON_CLOSE = Proc.new {$scene = Scene_Map.new}

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

class Scene_Questlog

def main

@window_header = Window_Help.new

@window_header.x = 65

@window_header.y = 28

@window_header.z = 500

@window_header.width = 510

@window_header.windowskin = RPG::Cache.windowskin(WINDOWSKIN) unless

WINDOWSKIN.nil?

@window_header.contents = Bitmap.new(478, 32)

@window_header.contents.font.size = 30

@window_header.contents.draw_text(0, 0, 510, 32, HEADER_TEXT, 1)

@window_titles = Window_Questlog_Titles.new

@window_titles.windowskin = RPG::Cache.windowskin(WINDOWSKIN) unless

WINDOWSKIN.nil?

@window_description = Window_Questlog_Description.new(

$game_system.questlog.quests.map{|q| q.description})

@window_description.windowskin = RPG::Cache.windowskin(WINDOWSKIN) unless

WINDOWSKIN.nil?

@index = @window_titles.index

spriteset = Spriteset_Map.new

Graphics.transition

loop do

Graphics.update

Input.update

update

if $scene != self

break

end

end

Graphics.freeze

@window_header.dispose

@window_titles.dispose

@window_description.dispose

spriteset.dispose

end

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

def update

@window_titles.update

if Input.trigger?(Input::B)

$game_system.se_play($data_system.cancel_se)

ON_CLOSE.call

return

end

if Input.press?(Input::R)

@window_description.scroll_down

elsif Input.press?(Input::L)

@window_description.scroll_up

end

if @index != @window_titles.index

@window_description.index = @index = @window_titles.index

end

end

end

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

class Quest

attr_reader :title

attr_reader :description

def initialize(title, description)

@title = title

@description = description

end

end

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

class Questlog

attr_reader :quests

def initialize

@quests = []

end

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

def add(quest, description="")

return add(Quest.new(quest, description)) unless quest.is_a?(Quest)

i = index(quest.title)

return @quests[i] = quest if i != nil

if INSERT_AT_TOP

# insert quest at top of the list

@quests.unshift(quest)

else

# insert quest at bottom of the list

@quests.push(quest)

end

end

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

def remove(title)

@quests.delete_if{ |quest| quest.title == title}

end

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

def count

return @quests.length

end

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

def index(title)

for i in [email=0..@quests.length]0..@quests.length[/email]-1

return i if @quests[i].title == title

end

return nil

end

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

def Questlog.add(title, description="")

$game_system.questlog.add(title, description)

end

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

def Questlog.remove(title)

$game_system.questlog.remove(title)

end

end

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

class Window_Questlog_Description < Window_Base

attr_reader :index

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

def initialize(descriptions)

super(275, 92, 300, 360)

@descriptions = descriptions

@cache = Array.new(descriptions.size)

self.contents = Bitmap.new(width-32, height-32)

self.index = 0

self.z = 500

end

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

def index=(index)

return if index == @index or @descriptions.empty?

@index = index

self.oy = 0

# bitmaps are only rendered once and than cached to reach more efficiency

if @cache[index].nil?

buffer = Bitmap.new(width-32, 2000)

docheight = buffer.draw_html(0, 0, 270, 2000, @descriptions[index])

@cache[index] = self.contents = Bitmap.new(width-32, docheight)

self.contents.blt(0, 0, buffer, Rect.new(0, 0, self.width-32, docheight))

else

self.contents = @cache[index]

end

end

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

def scroll_down

self.oy += SCROLL_SPEED if self.height + self.oy - 32 < self.contents.height

end

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

def scroll_up

self.oy -= SCROLL_SPEED

self.oy = 0 if self.oy < 0

end

end

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

class Window_Questlog_Titles < Window_Base

attr_reader :index

def initialize

super(65, 92, 210, 360)

self.z = 500

@item_max = $game_system.questlog.count

self.contents = Bitmap.new(width-32, @item_max > 0 ? @item_max*32 : 32)

@index = 0

refresh

end

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

def index=(index)

@index = index

update_cursor_rect

end

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

def top_row=(row)

if row < 0

row = 0

end

if row > @item_max - 1

row = @item_max - 1

end

self.oy = row * 32

end

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

def page_row_max

return (self.height - 32) / 32

end

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

def page_item_max

return page_row_max * @column_max

end

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

def update_cursor_rect

if @index < 0

self.cursor_rect.empty

return

end

row = @index

top_row = self.oy / 32

if row < top_row

self.top_row = row

end

if row > top_row + (self.page_row_max - 1)

self.top_row = row - (self.page_row_max - 1)

end

self.cursor_rect.set(0, @index * 32 - self.oy, self.width - 32, 32)

end

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

def refresh

self.contents.clear

for i in 0...$game_system.questlog.count

quest = $game_system.questlog.quests[i]

y = i*32

self.contents.draw_html(4, y, 150, 32, quest.title)

end

end

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

def update

super

if self.active and @item_max > 0 and @index >= 0

if Input.repeat?(Input::DOWN) and

(Input.trigger?(Input::DOWN) or @index < @item_max - 1)

$game_system.se_play($data_system.cursor_se)

@index = (@index + 1) % @item_max

end

if Input.repeat?(Input::UP) and

(Input.trigger?(Input::UP) or @index > 0)

$game_system.se_play($data_system.cursor_se)

@index = (@index - 1 + @item_max) % @item_max

end

end

update_cursor_rect

end

end

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

class Scene_Map

def call_questlog

$game_temp.questlog_calling = false

$game_player.straighten

$scene = Scene_Questlog.new

end

end

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

class Game_System

attr_accessor :questlog

alias questlog_init initialize

def initialize

questlog_init

@questlog = Questlog.new

end

end

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

class Game_Temp

attr_accessor :questlog_calling

alias questlog_init initialize

def initialize

questlog_init

@questlog_calling = false

end

end

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

class Scene_Load < Scene_File

# if a game that does not yet contain the questlog is loaded

# a new (empty) questlog instance is created

alias questlog_read_save_data read_save_data

def read_save_data(file)

questlog_read_save_data(file)

$game_system.questlog = Questlog.new if $game_system.questlog.nil?

end

end
 
quest%20icon%20fix_zpsyqhqiejy.png

The top highlighted line in green is the original (without the #)
Change it to the bottom line. The +4 is what the item menu uses to center the icon in the cursor box.

As you can see in your screenshot the line hugs the top of the cursor.
You might also consider +4 to the text line's positioning so its comfortably in the center of the rectangle.
center%20text_zpseoefiq0e.png


But this all depends on your Font & Text size, if you plan on changing it.
The shadow text line is above it, but I think you can ignore it. At the top of the script, Shadow is set to FALSE. If you change it to TRUE it adds a offset duplicate text as a shadow to all the text, which is dumb to leave it as all-or-none.
 
I changed this line at 124 blt(ix + 8, iy + LINE_HEIGHT/2 - 12, icon, Rect.new(0, 0, 24, 24))
with this one:
blt(ix + 8, y + 4 , icon, Rect.new(0, 0, 24, 24))

And at 161 I replaced this:
draw_text(x+ix+4, y+iy, 40, font.size, c)
with this:
draw_text(x+ix+4, y+iy+4, 40, font.size, c)

It worked. Thank you very much. You have helpt me yet again.
As I see your work in the forum, you know both scripting and pixeling, you are indeed very talented.
 

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