Debug - A whole new way of debugging your game

Showcase your games and demos, and discuss ongoing projects.

Debug - A whole new way of debugging your game

Postby kalle2990 on Wed Feb 09, 2011 4:55 pm

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

debug.png
Debugging Overlay above the NoGame screen
debug.png (66.11 KiB) Viewed 6192 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 327 times
debug.lua
Version 1.1.5
(8.29 KiB) Downloaded 813 times
Last edited by kalle2990 on Mon Apr 18, 2011 3:22 pm, edited 4 times in total.
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

Postby Robin on Wed Feb 09, 2011 6:29 pm

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
Robin
The Omniscient
 
Posts: 6012
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands

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

Postby kalle2990 on Wed Feb 09, 2011 6:55 pm

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
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

Postby BlackBulletIV on Wed Feb 09, 2011 8:42 pm

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
BlackBulletIV
Inner party member
 
Posts: 1253
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia

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

Postby miko on Wed Feb 09, 2011 11:38 pm

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
miko
Party member
 
Posts: 389
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

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

Postby Lap on Wed Feb 09, 2011 11:40 pm

The ultimate addition would be autocomplete for functions, especially unique ones defined by the running .love file. Not an easy task though.
User avatar
Lap
Party member
 
Posts: 247
Joined: Fri Apr 30, 2010 3:46 pm

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

Postby tentus on Thu Feb 10, 2011 2:16 am

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
tentus
Inner party member
 
Posts: 1050
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia

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

Postby Chief on Thu Feb 10, 2011 11:36 am

This is the finest sort of awesome! I'll be using it right away! :awesome:
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

Postby vrld on Thu Feb 10, 2011 1:00 pm

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 284 times
When I was a kid I used to pray every night for a new bicycle. Then I realised God doesn’t work that way, so I stole one and prayed for forgiveness.
hump Helper Utilities for Massive Productivity | HardonCollider Collision detection | Quickie Easy GUI Library
User avatar
vrld
Party member
 
Posts: 834
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany

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

Postby Taehl on Thu Feb 10, 2011 2:09 pm

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.
User avatar
Taehl
Dreaming in associative arrays
 
Posts: 997
Joined: Mon Jan 11, 2010 5:07 am
Location: FL, USA

Next

Return to Projects and Demos

Who is online

Users browsing this forum: No registered users and 9 guests