search
HomeDevelopment ToolsVSCodeWhat to do if vscode lua breakpoint fails

What to do if vscode lua breakpoint fails

What should I do if the lua breakpoint fails in vscode?

Using VSCode breakpoints to debug Lua tutorial

1. Install Visual Studio Code (vscode) and search and install luaide in the Plug-in Center

What to do if vscode lua breakpoint fails

2. Configure luach.json

1. Drag the project folder directly into vscode

2. Debug icon in the left column->Settings-> ;Select LuaDebug, and the launch.json file will appear

What to do if vscode lua breakpoint fails

3. Find the exePath field in the launch.json file and modify it to the simulator path

For example : "exePath": "D:/xxx/player-3.x/player3.exe",

Just configure the default in other places.

三.lua breakpoint debugging configuration

1. Download the file LuaDebug.lua

Address: https://github.com/k0204/LuaIde

What to do if vscode lua breakpoint fails

2. Place the LuaDebug.lua file in the project src directory

What to do if vscode lua breakpoint fails

3. Add debugging code

Add the following code in the main.lua file:

        local breakInfoFun,xpcallFun = require("LuaDebug")("localhost", 7003)
           
            --3.x
            --1.断点定时器添加
            cc.Director:getInstance():getScheduler():scheduleScriptFunc(breakInfoFun, 0.3, false)
            --2.程序异常监听
            function G__TRACKBACK(errorMessage)
            debugXpCall();
            print("----------------------------------------")
            local msg = debug.traceback(errorMessage, 3)
            print(msg)
            print("----------------------------------------")
            end
            local status, msg = xpcall(main, G__TRACKBACK)
            --如果是2.x
            CCDirector:sharedDirector():getScheduler():scheduleScriptFunc(breakInfoFun, 0.3, false)
            function G__TRACKBACK(errorMessage)
            debugXpCall();
            print("----------------------------------------")
            local msg = debug.traceback(errorMessage, 3)
            print(msg)
            print("----------------------------------------")
            end
            local status, msg = xpcall(main, G__TRACKBACK)

What to do if vscode lua breakpoint fails

##4. Debugging:

1. Press F5 to start debugging

Debugging Once started, the debug command bar will be displayed at the top of the editor

What to do if vscode lua breakpoint fails

Continue/Pause F5

Skip F10

Enter F11

Exit Shift F11

Restart unassigned

Stop debugging Shift F5

2. Click the debug icon in the left view bar of VS Code to open debugging view.

What to do if vscode lua breakpoint fails

3. Some debugging tips

1 The variable area can not only visually see the value, but also directly edit the variable value for debugging, or hover the mouse Edit on the source code in the editor.

2 If you want to keep tracking a certain variable, you can edit that variable into the monitor.

3 Using the call stack, you can know who made the error when the error function was called. By looking at it layer by layer, you can sometimes guess the cause of the error.

4 When the source code is not available but the function name is known, you can create a breakpoint function by pressing at the head of the breakpoint area.

What to do if vscode lua breakpoint fails

5. Edit user code snippets (Snippets)

Menu bar->File->Preferences->User code snippets-> lua

What to do if vscode lua breakpoint fails

Parameter explanation:

prefix : This parameter is a quick entry to use the code segment. For example, the log here will have intelligent perception when inputting the log during use. .

body : This is the main body of the code segment. The code that needs to be set is placed here. If there are line breaks between strings, use \r\n newline characters to separate them. Note that if the value contains special characters, they need to be escaped. .

Multi-line statements are separated by,.

$1 : This is the position of the cursor.

$2 : After using this parameter, a new line will start at the next position of the cursor. Press the tab key to quickly switch. You can also have $3,$4,$5....

description: code segment description, description when using intelligent sensing

The above is the detailed content of What to do if vscode lua breakpoint fails. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to format json with vscodeHow to format json with vscodeApr 16, 2025 am 07:54 AM

The ways to format JSON in VS Code are: 1. Use shortcut keys (Windows/Linux: Ctrl Shift I; macOS: Cmd Shift I); 2. Go through the menu ("Edit" > "Format Document"); 3. Install JSON formatter extensions (such as Prettier); 4. Format manually (use shortcut keys to indent/extract blocks or add braces and semicolons); 5. Use external tools (such as JSONLint and JSON Formatter).

How to compile vscodeHow to compile vscodeApr 16, 2025 am 07:51 AM

Compiling code in VSCode is divided into 5 steps: Install the C extension; create the "main.cpp" file in the project folder; configure the compiler (such as MinGW); compile the code with the shortcut key ("Ctrl Shift B") or the "Build" button; run the compiled program with the shortcut key ("F5") or the "Run" button.

How to install vscodeHow to install vscodeApr 16, 2025 am 07:48 AM

To install Visual Studio Code, please follow the following steps: Visit the official website https://code.visualstudio.com/; download the installer according to the operating system; run the installer; accept the license agreement and select the installation path; VSCode will start automatically after the installation is completed.

How to enlarge fonts with vscodeHow to enlarge fonts with vscodeApr 16, 2025 am 07:45 AM

The methods to enlarge fonts in Visual Studio Code are: open the settings panel (Ctrl, or Cmd,). Search and adjust "Font Size". Choose "Font Family" with the right size. Install or select a theme that provides the right size. Use keyboard shortcuts (Ctrl or Cmd) to enlarge the font.

How to connect to a remote server with vscodeHow to connect to a remote server with vscodeApr 16, 2025 am 07:42 AM

How to connect to a remote server through VSCode? Install Remote - SSH Extended Configuration SSH Create a Connection in VSCode Enter connection information: Host, Username, Port, SSH Key Double-click the saved connection in Remote Explorer

How to run vue with vscodeHow to run vue with vscodeApr 16, 2025 am 07:39 AM

Running a Vue project in VSCode requires the following steps: 1. Install the Vue CLI; 2. Create a Vue project; 3. Switch to the project directory; 4. Install project dependencies; 5. Run the development server; 6. Open the browser to visit http://localhost:8080.

How to compare two files with vscodeHow to compare two files with vscodeApr 16, 2025 am 07:36 AM

How to compare files in VSCode: 1. Open two files, 2. Enable the Differences view (View menu), 3. View the Differences (Add green, delete red, modify purple), 4. Use the arrow keys to navigate, 5. Accept or reject changes. Additional features include merging changes, copying changes, viewing details, and editing differences.

How to run js code with vscodeHow to run js code with vscodeApr 16, 2025 am 07:33 AM

How to run JS code in VSCode? Create .js files and write code; install Node.js and npm; install Debugger for Chrome; open the debug console; select Chrome; add debug configuration; set debug scripts; run code; debug code (optional).

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.