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.

Console Output

Console Output Version: 1.0
By: ForeverZer0

Introduction

Redirects output using the "puts" command to a separate console, instead of using the normal pop-up windows.
Not 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

[rgss]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
[/rgss]
 
To give the ouput the same functionality of the "p" method where it shows the inspected object, just add this code any 'ol where:
 
[rgss]alias zer0_console_inspect puts
def puts(*args)
  inspected = args.collect {|arg| arg.inspect }
  zer0_console_inspect(*inspected)
end
[/rgss]

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

No known compatibility issues.

Author's Notes

Please report any bugs/issues so that they can be resolved. Enjoy!

Terms and Conditions

Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
You are free:

to Share - to copy, distribute and transmit the work
to Remix - to adapt the work

Under the following conditions:

Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

Noncommercial. You may not use this work for commercial purposes.

Share alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

- For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.

- Any of the above conditions can be waived if you get permission from the copyright holder.

- Nothing in this license impairs or restricts the author's moral rights.
 

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