Quick Debugger

RPG Maker (RGSS)

Quick Debugger

A very useful quick debug tool that we can use as a probe in our code.

In a previous tutorial, we had tested the built-in Window class. We can use the same knowledge to construct a quick debugger, which can be used as a probe to collect data very quickly during development. P.S: RPG Maker has a debugger, but for personal reasons I prefer to use this quick debugger. This one I’m sharing here is a ‘lite’ version of the one I’m using for RPG Maker scripting development.

Without further ado, let’s follow these steps:

1-) Open RPG Maker VX and open the Script Editor. Hotkey is F11.
2-) Delete every file-based section of code. Absolutely everything. Hotkey is Del for each entry.
3-) Create three new files. Hotkey is Ins in the file-like explorer section.
4-) Enter the following pieces of code in the editor, each in a different file-based entry.

QWindow

class QWindow < Window

def initialize(x, y, width, height)
super

filename = "Window"
path = "Graphics/System/" + filename
bmp = Bitmap.new(width, height)

self.windowskin = Bitmap.new(path)
self.contents = bmp
self.arrows_visible = false
end

def draw_text(*args)
self.contents.draw_text(*args)
end

def display_text(text)
draw_text(0,-10,width, height, text)
end

end

QDebug

class QDebug

def initialize
@windows = []

x = 0
y = Graphics.height - 48
height = 45
width = Graphics.width

@windows.push( QWindow.new(x, y, width/2, height) )
@windows.push( QWindow.new(x+width/2, y, width/2, height) )
end

def refresh(index, string)
@windows[index].contents.clear
@windows[index].display_text(string)
end

def update(param1, param2)
update_info(@windows[0], param1)
update_info(@windows[1], param2)
end

def update_info(obj, param)
obj.contents.clear
obj.display_text(param)
end

end

Test Section

Graphics.resize_screen(640, 480)
@debug = QDebug.new

@debug.refresh(0, "hello world")
@debug.refresh(1, "This is a quick debugger.")

loop do
Graphics.update
end

I won’t explain every bit of the code, but QWindow stands for Quick Window. This window is a child of the built-in Window class and allows to display a string on the screen. QDebug stands for Quick Debug. This class allows to hold many instances of QWindow objects as a single object. In this version, I’m only using two windows to keep things simple, but in larger projects I’m allowing at least 8 CWindow objects to display information, but you can add more of them when necessary. By the way, the QDebug class can adapt different size of the screen automatically, you can test it by commenting out the Graphics.resize_screen(640, 480) line.

This debug script will be just perfect for analyzing data in upcoming demos.

Leave a Reply

Your email address will not be published. Required fields are marked *