Page 1 of 1

An Easy to Integrate In-Game Console

Posted: Wed Apr 14, 2021 3:05 am
by varunprime
demo.png
demo.png (272.02 KiB) Viewed 19104 times
I recently upgraded one of my old libraries to LOVE 11.3. I figured people might find it useful - https://github.com/rameshvarun/love-console

It's a single file in-game console that you can use for debugging your games. It's easy to integrate and doesn't take over your game loop or install any globals.

Code: Select all

local console = require "console"

function love.keypressed(key, scancode, isrepeat)
  console.keypressed(key, scancode, isrepeat)
end

function love.textinput(text)
  console.textinput(text)
end

function love.draw()
  console.draw()
end

-- This table is available as "player" in the console scope.
console.ENV.player = {x = 100, y = 5}

console.COMMANDS.save = function()
  -- This function is run when the user types "save" into the console.
end

Re: An Easy to Integrate In-Game Console

Posted: Wed Apr 14, 2021 8:55 am
by Gunroar:Cannon()
Yeah!! I totally fond it useful. I've wanted something like this for a while.

Edit:*found, not fond :P

Re: An Easy to Integrate In-Game Console

Posted: Wed Apr 14, 2021 11:15 am
by Xii
Looks simple, clean, and very useful, indeed. Thanks for sharing, will probably use. :)

Re: An Easy to Integrate In-Game Console

Posted: Wed Jun 09, 2021 12:08 am
by Xii
Was delightfully simple to integrate. Only needed a tiny tweak:
The tilde key ~ on my keyboard layout (finnish) is somewhere else, so I added:

Code: Select all

function console.enable(enable)
	enabled = enable
	return enabled
end
In order to map the console to F1 instead:

Code: Select all

function love.keypressed(key, scancode, isrepeat)
	if key == "f1" then
		console.clear()
		console.enable(not console.isEnabled())
	end
	console.keypressed(key, scancode, isrepeat)
end

Re: An Easy to Integrate In-Game Console

Posted: Thu Jun 10, 2021 2:17 am
by Xii
I see references in the code to colored text, but console.draw() doesn't actually draw colored text. Incomplete functionality?

Re: An Easy to Integrate In-Game Console

Posted: Tue Sep 07, 2021 4:26 am
by mozt
it 's useful ,but maybe a hightlight would be better

Re: An Easy to Integrate In-Game Console

Posted: Wed Jun 29, 2022 12:20 pm
by MarkD
Hello.
I am new to programming. To do an integration, do I necessarily need to have a very good knowledge of APIs?