如何构建我的 C++ 项目以将所有 Lua 文件包含在一个可执行文件中?我不希望人们能够编辑 Lua 文件并改变游戏。
这可能吗,是否合乎道德?
最佳答案
使用 LuaJIT 的“embedded bytecode”特性:
To statically embed the bytecode of a module in your application, generate an object file and just link it with your application.
require() tries to load embedded bytecode data from exported symbols (in *.exe or lua51.dll on Windows) and from shared libraries in package.cpath.
例子:
luajit -b test.lua test.obj # Generate object file
# Link test.obj with your application and load it with require("test")
关于c++ - 与项目一起构建 Lua 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22885455/