summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-15 04:05:31 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-15 04:05:31 -0800
commit3be53369f544187af7bb88b1ee284ab1348f32af (patch)
tree2fa8af73c0cf9ea2be3df7159cbf9163799c8958 /crawl-ref/source
parentdf940b3d40577cd05d71ebe7613f0dec1f115e91 (diff)
downloadcrawl-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')
-rw-r--r--crawl-ref/source/initfile.cc9
-rw-r--r--crawl-ref/source/luaterp.cc17
-rw-r--r--crawl-ref/source/options.h3
3 files changed, 27 insertions, 2 deletions
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 69496fda15..41a3d66371 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -819,6 +819,7 @@ void game_options::reset_options()
#ifdef WIZARD
wiz_mode = WIZ_NO;
+ terp_files.clear();
#endif
#ifdef USE_TILE
@@ -1976,7 +1977,7 @@ void game_options::read_option_line(const std::string &str, bool runscript)
&& key != "autopickup_exceptions"
&& key != "stop_travel" && key != "sound"
&& key != "travel_stop_message" && key != "force_more_message"
- && key != "drop_filter" && key != "lua_file"
+ && key != "drop_filter" && key != "lua_file" && key != "terp_file"
&& key != "note_items" && key != "autoinscribe"
&& key != "note_monsters" && key != "note_messages"
&& key.find("cset") != 0 && key != "dungeon"
@@ -2150,6 +2151,12 @@ void game_options::read_option_line(const std::string &str, bool runscript)
mprf(MSGCH_ERROR, "Lua error: %s", clua.error.c_str());
#endif
}
+ else if (key == "terp_file" && runscript)
+ {
+#ifdef WIZARD
+ terp_files.push_back(field);
+#endif
+ }
else if (key == "colour" || key == "color")
{
const int orig_col = str_to_colour( subkey );
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
diff --git a/crawl-ref/source/options.h b/crawl-ref/source/options.h
index 3abd9bc1e6..b344176e99 100644
--- a/crawl-ref/source/options.h
+++ b/crawl-ref/source/options.h
@@ -168,7 +168,8 @@ public:
std::string pizza;
#ifdef WIZARD
- int wiz_mode; // yes, no, never in wiz mode to start
+ int wiz_mode; // no, never, start in wiz mode
+ std::vector<std::string> terp_files; // Lua files to load for luaterp
#endif
// internal use only: