https://github.com/rameshvarun/love-console
An easy to integrate in-game console for Love2D games.
https://github.com/rameshvarun/love-console
love2d love2d-library
Last synced: about 1 month ago
JSON representation
An easy to integrate in-game console for Love2D games.
- Host: GitHub
- URL: https://github.com/rameshvarun/love-console
- Owner: rameshvarun
- License: isc
- Created: 2017-01-06T03:29:08.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-09-04T20:33:45.000Z (over 1 year ago)
- Last Synced: 2025-03-17T11:55:02.141Z (about 1 month ago)
- Topics: love2d, love2d-library
- Language: Lua
- Homepage:
- Size: 296 KB
- Stars: 23
- Watchers: 1
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# love-console

## Features
- Activate and deactivate the console with the `~` key.
- Use the `left` and `right` arrows to navigate the cursor.
- `alt-left` and `alt-right` navigate by word.
- `ctrl-left` and `ctrl-right` navigate to the end of the line.
- Evaluate both expressions and statements.
- Use the up and down arrow keys to access history.
- Use `_` to access the last returned value, and `last` to access all of the last returned values as a table.
- Use `ctrl+` and `ctrl-` to change font size.
- Type `clear` to clear the console.
- Add custom commands to `console.COMMANDS`.
- Use `console.ENV` to expose objects to the REPL.## Integrating the Console
```lua
local console = require "console"
love.keyboard.setKeyRepeat(true) -- Not required.function love.keypressed(key, scancode, isrepeat)
console.keypressed(key, scancode, isrepeat)
endfunction love.textinput(text)
console.textinput(text)
endfunction love.draw()
console.draw()
end-- This function is run when the user types "save" into the console.
console.COMMANDS.save = function()
-- Example: save game state
end-- This table is available as "player" in the console scope.
console.ENV.player = {x = 100, y = 5}
```