mac下minetest嵌入式lua脚本的断点和单步调试:
1 下载安装minetest和 ZeroBrane Studio
ZeroBrane Studio两种下载方式:
(1)github下载,解压,直接运行zbstudio.sh即可
https://github.com/pkulchenko/ZeroBraneStudio/releases
(2)网站下载dmg
https://studio.zerobrane.com
2 启动 ZeroBrane Studio.app
3 启动ZeroBrane Studio 调试服务器
Project菜单下面,Start Debugger Server
4 打开工程,即minetest_game的mods目录
将/Applications/minetest.app/Contents/Resources/games/minetest_game/mods拖到 Docker栏ZeroBrane Studio图标打开
5 编辑/Applications/minetest.app/Contents/Resources/games/minetest_game/minetest.conf,添加secure.enable_security = false 并保存,否则minetest的mod lua脚本不允许 require 指令。
6.zerobrane工程文件中找到 /Applications/minetest.app/Contents/Resources/games/minetest_game/mods/default/init.lua 并编辑,最开始default = {}之前添加如下代码,从而和zerobrane debug server 进行通讯:
package.path= package.path .. ";/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/?/?.lua;/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/?.lua;;";
package.cpath=package.cpath .. ";/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/?.dylib;;";
require("mobdebug").start()
7 运行应用程序下的minetest,进入首页菜单注意创建世界使用 Minetest Game (因为你打开的工程是/Applications/minetest.app/Contents/Resources/games/minetest_game/),点击 Play Game。
8 不出意外,/Applications/minetest.app/Contents/Resources/games/minetest_game/mods/default/init.lua 起始断点会自动在此文件 default = {} 激活,这样就可以单步调试minetest lua脚本了。