Hey guys: Here is a Tool Set script i finally made since i'm using it quite a lot, easier to have in one place !
Originally Made when I started Castlevania 3 years ago; I today compiled all in one place and improved the code I used a tiny bit.
Everything is explained in the Comments, I think you'll like it a lot !
[rgss]<span style="color:#000080; font-style:italic;">=begin
<span style="color:#000080; font-style:italic;">#===============================================================================
<span style="color:#000080; font-style:italic;">IDE Scripts
<span style="color:#000080; font-style:italic;">by Trebor777
<span style="color:#000080; font-style:italic;">v1.00
<span style="color:#000080; font-style:italic;">27/09/2010
<span style="color:#000080; font-style:italic;">Set of methods to help working on scripts outside of RM:
<span style="color:#000080; font-style:italic;">.Contain method to extract all the scripts
<span style="color:#000080; font-style:italic;">.to load or require scripts
<span style="color:#000080; font-style:italic;">.Create a console to override "p" dialog
<span style="color:#000080; font-style:italic;">#===============================================================================
<span style="color:#000080; font-style:italic;">=end
#-------------------------------------------------------------------------------
# Require a file, only once, return true if loaded properly
#-------------------------------------------------------------------------------
def require(dll)
$LOAD_PATH << "./"
p "Loading... #{dll}"
Kernel.send

require,dll)
end
#-------------------------------------------------------------------------------
# Load a file, like require, but can be called again if any change
# return true if loaded properly
#-------------------------------------------------------------------------------
def load(dll)
$LOAD_PATH << "./"
p "Loading... #{dll}"
begin
Kernel.send

load,dll)
rescue => error
send_error(error)
end
end
#-------------------------------------------------------------------------------
# Will extract all the scripts in rb files ordered with 3digits, and their name:
# 000_script_name.rb
# TAKES an HASH as argument, allows more flexibility for the parameters,
# and easier to read understand # inspired by ruby 1.9.1
#
# You can skip some scripts by providing an array containing the names of the
# scripts to skip, like this:
# extract_scripts({ :except => ["Main"] })
# will extract all the scripts except "Main"
#
# You can provide the name of a folder to extract the script ( will extract at
# the root of the folder if none provided:
# extract_scripts({ :folder => "My_scriptfolder/" })
#-------------------------------------------------------------------------------
def extract_scripts(options={})
except = options[:except] || [] # Define Default Values
folder = options[:folder] || ""
id = 0 # Set file ID
$RGSS_SCRIPTS.each do |script|
name = script[1] # Extract Script Name
data = script[3] # Extract Code
next if except.include? name or name.empty? or data.empty? # Skip invalid values
filename = sprintf("%03d", id) + "_" + name # Generate base file name
p "Writing: #{filename}"
File.open(folder+filename+".rb", "wb") do |file|
file.write data #Write the code
end
id += 1 # Increment file ID
end
end
#-------------------------------------------------------------------------------
# Load the all the scripts(rb files) from a specific folder, up to id "limit",
# and skipping ids in skip
# TAKES an HASH as argument, allows more flexibility for the parameters,
# and easier to read understand # inspired by ruby 1.9.1
# Example:
# .Load all from folder in Data/scripts: load_scripts( {:folder => "Data/Scripts/" })
# .Load all from root, but skip number 3 and 45: load_scripts({ :skip => [3,45] })
# .Load all from root, up to script with number 62: load_script({ :limit => 62 })
#-------------------------------------------------------------------------------
def load_scripts(options={})
skip = options[:skip] || []
folder = options[:folder] || ""
begin
# Load the language selection 1st
Dir.foreach(folder) do |file|
file_id = file[0,3].to_i
break if file_id == options[:limit]
next if file == "." or file == ".." or File.extname(file) != ".rb" or skip.include?(file_id)
r = load (folder+"#{file}")
p "Loaded: #{r}"
end
rescue => error
send_error(error)
end
end
#-------------------------------------------------------------------------------
if $DEBUG or $TEST
#-----------------------------------------------------------------------------
def p(*args) # Output to Console
args.each { | arg | puts arg.inspect }
end
#-----------------------------------------------------------------------------
def handle
game="\0"*256
ini=Win32API.new('kernel32','GetPrivateProfileStringA','pppplp', 'l')
ini.call('Game','Title','',game,255,".\\Game.ini")
return Win32API.new('user32','FindWindowEx','llpp','l').call(0,0,nil,game.delete!("\0"))
end
#-----------------------------------------------------------------------------
# Create Console
#-----------------------------------------------------------------------------
Win32API.new("kernel32", "AllocConsole", "V", "L").call
$stdout.reopen("CONOUT$")
$stdin.reopen('CONIN$')
Win32API.new("user32", "SetForegroundWindow", "L", "L").call(handle)
#-----------------------------------------------------------------------------
# Print error on Console
#-----------------------------------------------------------------------------
def send_error(error)
puts "Error : " + error
#puts "At : ", caller
puts "TRACE : " + error.backtrace.join("\n")
puts " "
puts " Going to EXIT - Press Enter to Continue - "
gets if $DEBUG or $TEST
end
end
[/rgss]
With this

you can edit your code while testing the demo at the same time...

if you use load_scripts, the edited scripts will be reloaded with F12 without problems, avoid losing time in closing demo, editing, saving, launch demo
Having a console to display your message, in a non blocking way(no dialogs freezing the game), helps a lot too ^^
HAve fun :thumb: