diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-15 04:05:31 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-15 04:05:31 -0800 |
commit | 3be53369f544187af7bb88b1ee284ab1348f32af (patch) | |
tree | 2fa8af73c0cf9ea2be3df7159cbf9163799c8958 /crawl-ref/source/luaterp.cc | |
parent | df940b3d40577cd05d71ebe7613f0dec1f115e91 (diff) | |
download | crawl-ref-3be53369f544187af7bb88b1ee284ab1348f32af.tar.gz crawl-ref-3be53369f544187af7bb88b1ee284ab1348f32af.zip |
luaterp (&^T): load files via terp_file option
You can now specify Lua files to be loaded for use in the wizard Lua
interpreter via "terp_file = file_path" in your init file. These
files will be run in the context of dlua, as opposed to the clua
context of files included with "lua_file = file_path".
Diffstat (limited to 'crawl-ref/source/luaterp.cc')
-rw-r--r-- | crawl-ref/source/luaterp.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/crawl-ref/source/luaterp.cc b/crawl-ref/source/luaterp.cc index 38219c775c..745cfbc12c 100644 --- a/crawl-ref/source/luaterp.cc +++ b/crawl-ref/source/luaterp.cc @@ -19,6 +19,9 @@ #include "cio.h" #include "clua.h" #include "dlua.h" +#include "options.h" + +#ifdef WIZARD static int _incomplete(lua_State *ls, int status) { @@ -126,7 +129,21 @@ void run_clua_interpreter(lua_State *ls) lua_settop(ls, 0); // clear stack } +static bool _loaded_terp_files = false; + void debug_terp_dlua() { + if (!_loaded_terp_files) + { + for (unsigned int i = 0; i < Options.terp_files.size(); i++) + { + dlua.execfile(Options.terp_files[i].c_str(), false, false); + if (!dlua.error.empty()) + mprf(MSGCH_ERROR, "Lua error: %s", dlua.error.c_str()); + } + _loaded_terp_files = true; + } run_clua_interpreter(dlua); } + +#endif |