Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tourahi/binocles
Debug your Love2D based game in a simple way.
https://github.com/tourahi/binocles
console console-debugger debug debugging dump ingame love2d love2d-framework watch-files watch-variable
Last synced: about 2 months ago
JSON representation
Debug your Love2D based game in a simple way.
- Host: GitHub
- URL: https://github.com/tourahi/binocles
- Owner: Tourahi
- License: gpl-3.0
- Archived: true
- Created: 2020-12-01T15:12:37.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-29T22:34:38.000Z (over 3 years ago)
- Last Synced: 2024-09-25T20:01:07.659Z (about 2 months ago)
- Topics: console, console-debugger, debug, debugging, dump, ingame, love2d, love2d-framework, watch-files, watch-variable
- Language: Lua
- Homepage:
- Size: 127 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Binocles
Debugging Love2D in a simple way.Binocles is a module based on Monocle https://github.com/kjarvi/monocle.
this module gives the ability to easily :1. watch variables and complex expressions
2. watch files and reload them when they change
3. Reloads the game after any watched files have been changed.
4. Custom colors
5. Add Global variables to the listener from the console.
6. Since the latest updates now you can watch nested tables recursively.The setup of a basic main.lua file is as follows:
Note : Make sure to run the game from the console or use --console so you can see the listener output.
```lua
Binocles = require("Binocles");
local test = 0;
local player = {
healt = 100,
x = 10,
y = 23.3,
skills_lvl = {
magic = 2,
conjuring = 4,
tinkering = 5,
sub_skills = {
magical_tinkering = 4
}
}
}function love.load(arg)
Binocles();
-- Watch the FPS
Binocles:watch("FPS", function() return math.floor(1/love.timer.getDelta()) end);
Binocles:watch("test",function() return test end);
Binocles:watch("player",function() return player end);Binocles:setPosition(10 ,1);
Binocles:watchFiles( { 'main.lua' } ); -- Add files so the game reloads if they changed.
Binocles:addColors( { {0.9,0.5,0.2,1.0} } ) -- Add colors to the pallete.--------------------------------------------------------------------------
-- You can use Binocles.dump to print an object to the console directly.--
--------------------------------------------------------------------------
endfunction love.update(dt)
Binocles:update();
endfunction love.draw()
Binocles:draw();
endfunction love.keypressed(key)
test = test + 1; -- inc test every time a key is pressed
Binocles:keypressed(key);
end```
* Result :
* ![Screenshot from 2021-03-04 22-47-06](https://github.com/maromaroXD/Binocles/blob/master/public/imgs/Screenshot%20from%202021-06-26%2012-13-57.png)For Moonscript:
```lua
export Binocles = assert require "Binocles"
with love
.load = () ->
Binocles!
Binocles\watch "FPS",-> love.timer.getFPS!
```Options :
* You can send an options array in the constructor : Binocles(options);
```lua
options.active -- if bonocles is active (drawing)
options.customPrinter -- activate printing to console
options.draw_x -- x pos of the Bonocles instance (Used in :draw())
options.draw_y -- y pos of the Bonocles instance (Used in :draw())
options.printColor -- text color (will be sent to love.graphics.setColor())
options.debugToggle -- Toggle (change the satate of self.active)
options.consoleToggle -- Start the interaction with the listener from the console
options.colorToggle -- toggle to change the printing color
options.watchedFiles -- files to watchoptions.restart --[[
* if true : Restarts the game without relaunching the executable. This cleanly shuts down the main Lua state instance and creates a brand new one.
* if false : will reload only the watched file if it got modified (ctrl-s).
]]--```
Console Example :
![Screenshot from 2021-03-04 22-47-06](https://github.com/maromaroXD/Binocles/blob/master/public/imgs/Screenshot%20from%202021-03-04%2022-47-06.png)
* Click "f3" Use "," as a delimiter:
![Screenshot from 2021-03-04 22-48-39](https://github.com/maromaroXD/Binocles/blob/master/public/imgs/Screenshot%20from%202021-03-04%2022-48-39.png)
![Screenshot from 2021-03-04 22-48-52](https://github.com/maromaroXD/Binocles/blob/master/public/imgs/Screenshot%20from%202021-03-04%2022-48-52.png)
* Or you can just give the table name :
![Screenshot from 2021-03-09 09-52-33](https://github.com/maromaroXD/Binocles/blob/master/public/imgs/Screenshot%20from%202021-03-09%2009-52-33.png)