Embedding Lua: how to programatically save a script to a folder, how to compile a script?
I am embedding Lua in a C++ application, and I am using luaL_dofile to load a script
However, I c开发者_StackOverflow社区annot seem to find documentation on the functions to use to:
- Compile a script (and save byte stream to a specified folder)
- Save a script to a specified folder
last but not the least, when I use luaL_dofile to load a script into the Lua engine, if the loaded script has a line that loads a module for example:
require 'strict'
which directory would the script.lua (or its compiled version) be loaded from?
Look up luaL_loadfile and lua_dump. See also test/luac.lua
.
For the question about where Lua looks for modules require'd: It depends on package.path
and package.cpath
variables, which can be influenced by the environment variables LUA_PATH
and LUA_CPATH
.
精彩评论