<code>brew install lua@5.4 code>
LuaPanda需要luasocket这个第三方库c;我们使用Luarocks来安装c;Luarocks是Lua的包管理器c;就像npm一样c;它可以帮助我们下载、查找、删除Lua包
首先安装Luarocks, 到http://luarocks.org/releases/下载源码c;我下载的是最新的3.11.1版本
https://luarocks.github.io/luarocks/releases/luarocks-3.11.1.tar.gz
<code>tar -zxvf luarocks-3.11.1.tar.gz cd luarocks-3.11.1 ./configure && make && sudo make install sudo luarocks install luasocket code>
https://github.com/Tencent/LuaPanda/tree/master/Debugger里面的LuaPanda.lua下载下来放到skynet/lualib目录下
这个文件是用来连接调试服务器的。
这个插件会开启调试服务器c;并能下断点进行单步调试
<code>root = "./" lua_cpath = root.."luaclib/?.so;".."/usr/local/lib/lua/5.4/?.so;" code>
<code>{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息c;请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "lua", "request": "launch", "tag": "normal", "name": "LuaPanda", "description": "通用模式,通常调试项目请选择此模式 | launchVer:3.2.0", "cwd": "${workspaceFolder}/game", "luaFileExtension": "", "connectionPort": 8818, "stopOnEntry": true, "useCHook": false, "autoPathMode": true }, ] } code>
useCHook必须要false, 如果为true会有段错误c;不知道为何。
<code>require("LuaPanda").start("127.0.0.1", 8818) code>
这段代码会连接VSCode调试服务端。
所有配置已经完成c;我们来尝试调试一下c;在你的lua文件中添加断点。 注意:必须要在require(“LuaPanda”).start(“127.0.0.1”, 8818)执行后 的断点才起作用。
然后运行skynet
如
<code>skynet game/config code>
是不是你的断点断下来了?
skynet.fork出来的方法是没办法下断的c;目前还没有摸索出方法c;有知道的朋友请告知一下。
参考:
https://blog.csdn.net/qq_41252394/article/details/124576105