Giter VIP home page Giter VIP logo

luabreakpoints's Introduction

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.

    require("breakpoints")

Usage

Insert the following line at the desired points in your code to set a breakpoint:

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

local function doSomeWork()
    local x = 10
    local y = 20
    local z = x + y

    breakpoint(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)
end

doSomeWork()

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.

luabreakpoints's People

Contributors

depilz avatar

Stargazers

Jeremy avatar Serkan Aksit avatar Kan avatar Steven Johnson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.