Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/depilz/LuaBreakpoints
Lua Breakpoints designed for solar2D
https://github.com/depilz/LuaBreakpoints
Last synced: 10 days ago
JSON representation
Lua Breakpoints designed for solar2D
- Host: GitHub
- URL: https://github.com/depilz/LuaBreakpoints
- Owner: depilz
- License: mit
- Created: 2024-07-15T13:00:52.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-07-15T13:17:10.000Z (4 months ago)
- Last Synced: 2024-07-31T09:10:34.873Z (3 months ago)
- Language: Lua
- Size: 4.88 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-solar2d - LuaBreakpoints - a utility that enables the integration of breakpoints. (Coding & Debugging)
README
# Solar2D - Breakpoints
This utility enables the integration of breakpoints into Solar2D projects. Breakpoints are essential for debugging, allowing developers to pause execution and inspect variables at specific code locations. Solar2D does not natively support breakpoints, and this tool provides a workaround to simulate this functionality.
## Installation
1. **Download:** Obtain the `breakpoints.lua` file from this repository.
2. **Add to Project:** Incorporate the file into your Solar2D project.
3. **Include in Code:** Import `breakpoints.lua` in your `main.lua` or in other Lua files where debugging is required.```lua
require("breakpoints")
```## Usage
Insert the following line at the desired points in your code to set a breakpoint:
```lua
breakpoint(id, fn)
```- `id` (number): A unique identifier for each breakpoint within a file.
- `fn` (function): A callback function for inspecting variables when the breakpoint is triggered.### How it Works
Upon reaching a breakpoint, the Solar2D simulator pauses execution, and the console displays the line where the breakpoint was set. To inspect or modify variables, you need to edit the callback function in your code file directly.
- **Edit and Continue**: Modify the callback function to inspect or change the values of variables. After making changes, ensure the callback function returns `true` and save the file (`Ctrl+S`) to continue execution.
**Note**: The scope of variables is fixed once the file is loaded. You cannot introduce new variables at the breakpoint; you can only manipulate variables that already exist in the function's scope.
### Example Usage
```lua
local function doSomeWork()
local x = 10
local y = 20
local z = x + ybreakpoint(1, function()
print("x: " .. x) -- Inspect x
print("y: " .. y) -- Inspect y
print("z: " .. z) -- Inspect z
return true -- Continue execution after inspection
end)print("The sum of x and y is: " .. z)
enddoSomeWork()
```## Ownership and License
**Creator**: Depilz
**Company**: Studycat Limited
This tool is distributed as open-source under the MIT License, allowing for modification and redistribution. We encourage enhancements and would love to see how you adapt it for your needs.