Version: 0.3
By: Berka
Introduction
I think the addition of the console has been the greatest feature of RMVX Ace: super handy for debugging scripts.
And that's why I could not resist the urge to customize this wonderful tool.
Features
- Syntax highlighting,
- Gets method,
- Line numbers,
- Simple color changer
Screenshots

Script
Code:
#============================================================
# Advanced RGSS3 Console
# Berka http://www.rpgmakervx-fr.com
# v0.5 VX Ace only. 01-21-12
#
# Thanks to Azuma-01 for symbols and regexp matching
# Free of use. Please ask me before publishing anywhere.
#
# Add a basic syntax haighlighter to the default RGSS Console
# May cause a slight slowdown in the console display.
#------------------------------------------------------------
# Use Kernel#puts to activate the syntax highlighter.
# Kernel#print stays unchanged.$
# Console#gets extracts the input of the console
# use: eval(Console.gets) to script while testing.
#------------------------------------------------------------
# Change the color of the console:
# Console.color(H_RED) # Set the color of the console
# print("this text is red") # Text displayed in red
# Console.color = nil # Remove the coloration
#============================================================
module Berka
module Console
LINE_NUMBERS = true # Display line numbers ON/OFF
BACKGROUND = true # Display a white background ON/OFF
ENABLEPROMPT = true # Enable the gets command ON/OFF
PARSE_P = false # Enable parsing for Kernel#p function /!\
end
end
module Win32
GSH ||= Win32API.new('kernel32','GetStdHandle','l','l')
SCTA||= Win32API.new('kernel32','SetConsoleTextAttribute','ll','l')
end
module Highlighter
H_BLACK = 0x0000 # black
H_DBLUE = 0x0001 # dark blue
H_DGREEN = 0x0002 # dark green
H_DCYAN = 0x0003 # dark cyan
H_DRED = 0x0004 # dark red
H_DPURPLE = 0x0005 # dark purple
H_DYELLOW = 0x0006 # dark yellow
H_GREY = 0x0007 # grey
H_DGREY = 0x0008 # dark grey
H_BLUE = 0x0009 # blue
H_GREEN = 0x000a # green
H_CYAN = 0x000b # cyan
H_RED = 0x000c # red
H_PURPLE = 0x000d # purple
H_YELLOW = 0x000e # yellow
H_WHITE = 0x000f # white
H_INTENSITY = 0x0080 # background intensity
# Ruby's special words
H_KWORDS=["alias","begin","BEGIN","break","case","defined","do","else","elsif",
"end","END","ensure","for","if","in","include","loop","next","raise",
"redo","rescue","retry","return","super","then","undef","unless",
"until","when","while","yield","false","nil","self","true","__FILE__",
"__LINE__","and","not","or","def","class","module","catch","fail",
"load","throw"]
# Ruby's operators
H_OPERATORS=["=","+","-","/","*","%",'(',')','[',']','{','}','<','>','&','|',
',','!',"?",":",";",'.']
def self.parse(*args)
args.flatten.each{|l|
Console.color=nil
print("#{sprintf("%03d",$consolelines+=1)}:\s")if Berka::Console::LINE_NUMBERS
l.split(/ /).each{|e|
case e
when *H_KWORDS then Console.color=H_BLUE
when /^\d*[.]?\d+$/ then Console.color=H_DRED
when /\/.*\/(?:[imx]{,3})/ then Console.color=H_DPURPLE # by Azuma-01
when /^:.*$/ then Console.color=H_DYELLOW # by Azuma-01
when /^#.*$/ then Console.color=H_DGREEN # by Azuma-01
else
e.split(//).each{|f|
@s=!@s if r=(f=='"'||f=="'")
if(@s)||r;Console.color=H_DPURPLE
elsif f=~/^\d*[.]?\d+$/;Console.color=H_DRED
else
Console.color=(H_OPERATORS.include?(f)? H_DCYAN : H_BLACK)
end
print(f)
}
print(" ")
next
end
print("#{e} ")
}
}
print("\n")
end
end
include Highlighter
module Console
$consolelines=0 # Console lines counter
def self.init
@outhwnd=Win32::GSH.call(-11)
end
def self.color=(c=H_BLACK)
Win32::SCTA.call(@outhwnd,(c||=H_BLACK)|(Berka::Console::BACKGROUND ? 0x00f0 : 0))
end
def self.gets
$stdin.gets
end
end
Console.init
# Kernel#puts redefinition
def puts(*a)
a.each{|n|Highlighter.parse(*n)}
end
#Kernel#p redefinition
def p(*a)
Berka::Console::PARSE_P ? (a.each{|b|puts b.inspect}) : Kernel.p(*a)
end
# Kernel#gets
def gets
Console.gets
end
Instructions
Paste this script above Vocab. Only the method Kernel#puts is modified. It enables the syntax highlighter:
Code:
puts("a = ['this is a test', 1.0]")
Code:
Console.color = H_RED
print("Ruby is amazing")
Compatibility
No issues known yet.
Credits and Thanks
All thanks go to the Msdn reference.
Terms and Conditions
This script is free to use. Credits are not mandatory, but it would be very nice of you to quote me. Please ASK me before posting this script anywhere. Because of that I can help you to use this script.
Best regards,
Berka