[XP][VX] Console Output Debugger

Started by ForeverZer0, November 25, 2010, 04:55:17 pm

Previous topic - Next topic

ForeverZer0

November 25, 2010, 04:55:17 pm Last Edit: November 25, 2010, 08:38:30 pm by ForeverZer0
Console Output
Authors: ForeverZer0
Version: 1.0
Type: Scripting Tool
Key Term: Scripting Tool



Introduction

Redirects output using the "puts" command to a seperate console, instead of using the normal pop-up windows.
Noy much more to it than that.


Features


  • Simple.
  • No annoying pop-up windows, though they still do have their uses.
  • Automatically sets the console window the background.



Screenshots

None.


Demo

None.


Script

Here.
Spoiler: ShowHide

if $DEBUG || $TEST
 # Create a console object and redirect standard output to it.
 Win32API.new('kernel32', 'AllocConsole', 'V', 'L').call
 $stdout.reopen('CONOUT$')
 # Find the game title.
 ini = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
 title = "\0" * 256
 ini.call('Game', 'Title', '', title, 256, '.\\Game.ini')
 title.delete!("\0")
 # Set the game window as the top-most window.
 hwnd = Win32API.new('user32', 'FindWindowA', 'PP', 'L').call('RGSS Player', title)  
 Win32API.new('user32', 'SetForegroundWindow', 'L', 'L').call(hwnd)
 # Set the title of the console debug window'
 Win32API.new('kernel32','SetConsoleTitleA','P','S').call("#{title} :  Debug Console")
 # Draw the header, displaying current time.
 puts ('=' * 75, Time.now, '=' * 75, "\n")
end


To give the ouput the same functionality of the "p" method where it shows the inspected object, just add this code any 'ol where:

Spoiler: ShowHide
alias zer0_console_inspect puts
def puts(*args)
 inspected = args.collect {|arg| arg.inspect }
 zer0_console_inspect(*inspected)
end




Instructions

Place the script anywhere you like.
In script calls or within scripts, output to it using "puts" instead of the normal "p" or "print".


Compatibility

Shouldn't be any.


Credits and Thanks


  • ForeverZer0, for the script.



Author's Notes

Please report any bugs/issues/suggestions. I will be happy to fix them.
Enjoy!
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

dose this work with the p and print commands too? or just puts?
in any case I've been wanting this for a while now. the pop up boxes make it hard to do debugging sometimes other times they are useful as they pause execution long enough to see data but keep the game running at full speed. this would of been real useful when I was making the DEE and dynamic sounds scripts.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ForeverZer0

Only with "puts". I left p and print alone, since it is sometimes useful to have exucution stop so you find exactly where something is going wrong.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.