Debug - A whole new way of debugging your game

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

Debug - A whole new way of debugging your game

Post by kalle2990 »

Tired of having to restart your whole game when an error occurs or attaching a console, which you have to switch to, just to see your debug printings? Tired of adding extra variable in text to your graphical experience, taking space and looks misplaced? Tired of not having the possibility to execute scripts in-game without attaching a GUI or even writing one yourself? Now all of this is unnecessary!

With the adding of only one script you can now access an in-game console using CTRL+F8 with many lovely features, including:
  • A scrollable list of the output
  • Both errors and printings are sent to the output
  • Only prints the same error once, useful for errors in love.update, can be toggled
  • Semi-transparent console overlay
  • CTRL/Shift + F8 toggle of the console
  • Text input for executing lua snippets right in your console
  • Graphic feedback telling about unseen lines
Debugging Overlay above the NoGame screen
Debugging Overlay above the NoGame screen
debug.png (66.11 KiB) Viewed 27746 times
I'll be continuing to add features such as keyholding and delete key (not to confuse with backspace) functionality for the input field as well as breaking lines which are too long for the screen and a similar feature for the input field. Please give me more ideas of what I could add :)

Note: Require the script outside all love core functions or it will not work.

Code: Select all

--Example
require("debug.lua")

function love.load()
end
Changelog
Version 1.1.5
  • Added Shift + F8 console opening, the old one still remains (Thank you miko)
  • Everything except for settings (which has its own global table) is now put into the local table _Debug (Thank you tentus)
Version 1.1
  • Fixed the console to be hidden at the start
  • Added _OverlayColor to global settings (see _Settings() for a list of settings) Changed location as of 1.1.5 to _DebugSettings.Settings()
Version 1.0
  • Initial version
Attachments
debug_unstable.lua
Unstable build containing some fixes and new features
(11.67 KiB) Downloaded 3058 times
debug.lua
Version 1.1.5
(8.29 KiB) Downloaded 2248 times
Last edited by kalle2990 on Mon Apr 18, 2011 3:22 pm, edited 4 times in total.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Debug - A whole new way of debugging your game

Post by Robin »

Nice, seems very useful!

Have you taken a look at other in-game consoles? They might give you ideas for improvement.
Help us help you: attach a .love.
User avatar
kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

Re: Debug - A whole new way of debugging your game

Post by kalle2990 »

I have only seen the one in Heroes of Newerth (non-transparent overlay) and in CS (windowed), so I pretty much started from scratch on the interface. There are some features which I feel is rather important, including up/down key tabbing for the recent commands used and maybe some way of adding a dynamic printing to the console using something like Watch(VariableName) instead of having to print the variable every time you wish to check for a change. I felt the transparency was quite important here as one can still interact in the game with the mouse (for more advanced debugging) plus the fact that a solid black background is just too boring in my opinion.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Debug - A whole new way of debugging your game

Post by BlackBulletIV »

Looks good (I haven't played with it yet) :). I'm to add something like this for Grace sometime (I've already got entity and physics outlines), I might take a look at your code to get some inspiration.
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Debug - A whole new way of debugging your game

Post by miko »

kalle2990 wrote: [*]CTRL + F8 toggle of the console
BTW, it does not for linux (at least for me) - looks like the window manager hijacks CTRL key, and CTRL+F8 is not passed to the love window. SHIFT+F8 would work.
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Re: Debug - A whole new way of debugging your game

Post by Lap »

The ultimate addition would be autocomplete for functions, especially unique ones defined by the running .love file. Not an easy task though.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Debug - A whole new way of debugging your game

Post by tentus »

Oh wow, this is cool stuff, I will probably end up using this. Any thoughts about moving everything into a class, so that variables/functions like order and overlay don't conflict with code we've already written?
Kurosuke needs beta testers
User avatar
Chief
Party member
Posts: 101
Joined: Fri Mar 12, 2010 7:57 am
Location: Norway, 67° north

Re: Debug - A whole new way of debugging your game

Post by Chief »

This is the finest sort of awesome! I'll be using it right away! :awesome:
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Debug - A whole new way of debugging your game

Post by vrld »

Curiously, recently I have done a similar thing: https://github.com/vrld/love-console (attached .love for convenience). Though it is less suited for debugging but focused on live-coding (or stuff)

Features:
- mimicking the Lua interpreter (multiline input)
- history (press up/down keys)
- tab completion (sort of programmable)
- error catching (i.e. no blue screen)
Attachments
console.love
(32.05 KiB) Downloaded 1201 times
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Debug - A whole new way of debugging your game

Post by Taehl »

Lap wrote:The ultimate addition would be autocomplete for functions, especially unique ones defined by the running .love file. Not an easy task though.
Search _G and every table it has for functions, save their names to a table (on load, not every frame). When typing in commands, sort the table according to how many beginning letters are the same between the table's names and the text. When enter is pressed, loadstring(text)().

That'd be pretty cool.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Post Reply

Who is online

Users browsing this forum: No registered users and 43 guests