summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/docs/options_guide.txt7
-rw-r--r--crawl-ref/source/initfile.cc9
-rw-r--r--crawl-ref/source/luaterp.cc17
-rw-r--r--crawl-ref/source/options.h3
4 files changed, 34 insertions, 2 deletions
diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt
index 1128495065..c8d4667aab 100644
--- a/crawl-ref/docs/options_guide.txt
+++ b/crawl-ref/docs/options_guide.txt
@@ -382,6 +382,13 @@ The available stock Lua scripts are
Also see section 7 on inline Lua fragments.
+The wizard-mode Lua interpreter (&^T) will, the first time it's invoked,
+load all of the files that are specified with the terp_file option:
+
+terp_file = <path/name.lua>
+
+The Lua in these files will have access to all of the Crawl Lua internals
+(that is, will be run in the context of dlua, not clua).
4- Interface.
==============
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: