## LoveDebug - A whole new way of debugging your game

Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

### LoveDebug - A whole new way of debugging your game

Originaly created and writen 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!

By pessing CTRL/Shift + F8 you'll have access to these key features in an on-screen console:
• Code Hotswapping, press F5 while you are at the console to reload your code or simply set _DebugSettings.LiveAuto to true to automaticly reload your code when it's changed, controle the files that should be monitored by editing _DebugSettings.LiveFile
• Pess CTRL/Shift + F8 to Show/Hide the console.
• Type _DebugSettings.Settings() to see a list of available variables that you can change.
• HUD feed of everything that is going on under the under the hood of you application in real time.
• Use the arrow keys while you are coding in the console to browse a list of possible autocompletions and press tab to autocomplete the word.
• Use Shift+Arrow keys to browse input histoy.
• Copy and Past by pressing Ctrl+V/C
Anyone can contribute to the development of this script, all you need to do is either to download the latest version on lovedebug, add your code and post it here with a change log or by forking the repo on github and send a Pull Request or by telling me/us new ideas to add to lovedebug.
Github's repo of LoveDebug.
I'll update this post with the new versions that you guys might post.

Using LoveDebug:
• Put 'lovedebug.lua' wherever you want. (Ex: root of the working directory)
• Add require('lovedebug') to the beginning of you code in main.lua Ex:

Code: Select all

require("lovedebug")

end
• Lunch your game and press Ctrl/Shit + F8
• And there you have it, your own onscreen interactive console.
• For more help just run _DebugSettings.Settings()

Latest Unofficial Version 1.4.4 by beuz
[attachment=0]lovedebug.lua[/attachment]

Latest Official Version 1.1.5 (might not work):
[attachment=1]lovedebug.lua[/attachment]

Complete list of features:
• A scrollable list of the output.
• Some errors are reedirected to the console instead of crashing löve.
• Only prints the same error once, useful for errors in love.update, can be toggled.
• Semi-transparent console overlay, the console's color can be changed in _DebugSettings.OverlayColor
• CTRL/Shift + F8 toggle of the console
• Text input for executing lua snippets right in your console
• Graphic feedback telling about unseen lines ("..." on the bottom right)
• Variable proposal and autocomplition (select a proposal by using the arrow keys and press tab to autocomplete).
• Fast jumping to the bottom of the console by pressing lCtrl+Middle mouse button or by providing a code to the console.
• Use the home and the end keys to jump to the end or to beginning of the line.
• Browse code history by using the arrow keys while pressing the Shift key.
• LiveCoding, you can reload your code by pressing F5 while at the console or by setting _DebugSettings.LiveAuto to true and you can reload more than one file, see _DebugSettings.Settings().
• Type 'clear' and press enter to clear the console.
• Type Ctrl+C/V to copy or to past text into the console input.
• HUD with the latest prints and errors that your application emitted.
Changelog
Version 1.4.4 (Not Official) by beuz
• Fixed commented lines.
Version 1.4.3 (Not Official) by Ranguna259
• Fixed some incompatibilities with LÖVE 0.10.0's love.run, the background color will not reset to black now and this should probably fix loads of other unknown bugs.
Version 1.4.2 (Not Official) by Ranguna259
• Updated to LÖVE 0.10.0.
Version 1.4.1 (Not Official) by Ranguna259
• Fixed a bug where the overlay console wouldn't show up correcly when using stencils.
Version 1.4.0 (Not Official) by Ranguna259
• Added prints and news feed on top of your screen. This way you won't miss any error that might show up.
Version 1.3.5 (Not Official) by admin36
• Added two new settings, HaltExecution and AutoScroll.
• HaltExecution: setting to control if execution of the love program is halted while console is open
• AutoScroll: setting to control if the console auto scrolls once output fills the console.
Version 1.3.4 (Not Official) by Ranguna259
• Fixed a bug where the console was not appearing.
Version 1.3.3 (Not Official) by Ranguna259, thanks Davidobot
• You can now use tables in _DebugSettings.LiveFile to reload multiple files.
• Errors from reloaded files are now printed with an "[ERROR]" prefix. (forgot to write this on github)
Version 1.3.2 (Not Official) by Ranguna259
• Fixed a bug where keys weren't being detected when Ctrl or Shift keys were being pressed.
Version 1.3.1 (Not Official) by Ranguna259
• By setting _DebugSettings.LiveAuto to true the code will automaticly reload itself when it's modified.
• You can now Copy and Past by pressing Ctrl+C/V
Version 1.3 (Not Official) by Ranguna259
• Converted to LÖVE 0.9.0
• To jump to the bottom of the console you now have to press lCtrl+middle mouse buttons instead of just the middle mouse button.
• You can now do code hotswapping by accessing the console and by pressing the F5 button.
Version 1.2.9 (Not Official) by Robin
• Some more cleaning up of the code.
• Fixes auto-complete options not being reset in certain conditions.
• Adds a command history, navigatable with up and down arrow keys. This conflicts with selection of auto-complete options, but you can force history navigation by using shift+up and shift+down.
• Reworks error-checking in entered commands. A nice benefit is that the [string "possibly a long command"]:1: part no longer shows up, which just duplicated something that was printed right before.
Version 1.2.8 (Not Official) by Robin
• Improves _Debug.findLocation (including: no more loadstring, no __index side-effects, finding object:methods).
• Improves _Debug.updateProposals (only valid identifiers are proposed, keywords are proposed if there is no preceding . or :).
• Adds support for the home and end keys.
• Cleans up some dead code.
• Now only allows you to enter characters in ASCII, because the rest of the library handles non-ASCII unicode very poorly.
• Auto-complete now works when inserting text in the middle instead of only at the end.
• Up and down change which auto-complete option you're going to select.
• Much better drawn auto-complete options.
• Suppresses auto-complete when in the middle of an identifier.
Version 1.2.7 (Not Official) by Robin
• Brings back keyRepeat, in a way that doesn't interfere with the game.
• Fixes printing multiple things in 3 ways (see if you can find them all!).
• Syntax errors in commands now get a sensible error message.
• Tab completion now only done when the overlay is visible.
• Removes a useless loop in _Debug.findLocation.
• Uses multiple argument form of love.keyboard.isDown in _Debug.handleKey.
Version 1.2.6 (Not Official) by Robin
• Removes keyRepeat, because that shit's evil.
• Fixes "double click" bug.
• Fixes indentation.
Version 1.2.5 (Not Official) by Eamonn
• We now have repetitive keyboard behavior, AWESOME
Version 1.2.4 (Not Official) by Ranguna259
• Added a new functionality that jumps you to the last output in the conole when you provide a command
Version 1.2.3 (Not Official) by Walz.
• Fixed a font related bug
Version 1.2.2 (Not Official) by Ranguna259
• Added a new functionality that enables you to jump right to the bottom of the console by pressing the middle mouse button.
Version 1.2.1 (Not Official) by Qcode
• Fixed some bugs
• Added a new functionality that autocompletes the variable to the current proposal by pressing tab
Version 1.2 (Not Official) by Qcode
• Converted to LÖVE 0.8.0
• Added a new functionality that enables you to change the 'f8' key to what you want by changing the _lovedebugpresskey='the key you want'
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
lovedebug.lua
1.4.4
lovedebug.lua
Official Outdated LoveDebug 1.1.5
Last edited by Ranguna259 on Thu Sep 15, 2016 1:07 pm, edited 15 times in total.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping

Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Contact:

### Re: LoveDebug - A whole new way of debugging your game

Nice work.
I'd like to point something. When you are about to make a new release, I'd suggest taggng it as a full release on the Github repo.

Code: Select all

git tag -a x.x.x -m "version x.x.x"
Assuming x.x.x refers to the version to be released.

Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

### Re: LoveDebug - A whole new way of debugging your game

Oh cool, Thanks I didn't know I could do that
Version 1.3.1 tagged on github.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping

Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Contact:

### Re: LoveDebug - A whole new way of debugging your game

Awesome. And in case you end up messing with tags (as I always do) this reference might be of help. More precisely this section.
And I think it'll be much more sexy if you add a screenshot showing LoveDebug in action in the Readme page.

Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

### Re: LoveDebug - A whole new way of debugging your game

Thanks again, I'm actually messing with everything on github right now (if you see any wierd stuff on lovedebug repo then that was me, testing) so that's gonna help alot.
Will do .
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping

Davidobot
Party member
Posts: 1155
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

### Re: LoveDebug - A whole new way of debugging your game

Can you use a table in _DebugSettings.liveFile?

And what is _G?
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: LoveDebug - A whole new way of debugging your game

Davidobot wrote:And what is _G?
In Lua, the global environment is a table. That table has an entry "_G" which points to the global environment table itself. Thus _G is a global variable that points to the global environment table.

Code: Select all

_G._G == _G
_G.print == print
_G.require == require
_G.math == math
--etc.

Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

### Re: LoveDebug - A whole new way of debugging your game

Davidobot wrote:Can you use a table in _DebugSettings.liveFile?
No but that's a good idea, it shouldn't be hard to code, give me a few minutes.

EDIT: Forgot that I had actual work to do , I'll code this once I get home.

Today was a busy day indeed, you can now use tables .
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping

soulaymenc
Prole
Posts: 34
Joined: Thu Jul 11, 2013 2:03 pm
Contact:

### Re: LoveDebug - A whole new way of debugging your game

This made my life easier thank you

for some reason, when I first saw the project name, i thought it was "loved bug" xD
This world is so strange.

Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you