summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/clua.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-12 22:47:16 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-12 22:47:16 +0000
commit7a66364b0a9a5ee83119698e5d84b8293d3b3b62 (patch)
tree06539d816f9848f0f190c38df9e70d89bac3b778 /crawl-ref/source/clua.cc
parent53c6ceba3b668484834997f285d25cffa0c07eca (diff)
downloadcrawl-ref-7a66364b0a9a5ee83119698e5d84b8293d3b3b62.tar.gz
crawl-ref-7a66364b0a9a5ee83119698e5d84b8293d3b3b62.zip
Added crawl.process_keys to user Lua API to allow a Lua macro to ask Crawl to process keystrokes immediately, i.e., not wait until the macro has finished running. Also removed player EV penalty during run/rest/travel.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7443 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/clua.cc')
-rw-r--r--crawl-ref/source/clua.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index 3edabd36f0..477d772a40 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -1810,6 +1810,25 @@ static int crawl_sendkeys(lua_State *ls)
return (0);
}
+// Tell Crawl to process one command.
+static int crawl_process_command(lua_State *ls)
+{
+ const bool will_process =
+ current_delay_action() == DELAY_MACRO || !you_are_delayed();
+
+ if (will_process)
+ {
+ // This should only be called from a macro delay, but run_macro
+ // may not have started the macro delay; do so now.
+ if (!you_are_delayed())
+ start_delay(DELAY_MACRO, 1);
+ start_delay(DELAY_MACRO_PROCESS_KEY, 1);
+ }
+
+ lua_pushboolean(ls, will_process);
+ return (1);
+}
+
static int crawl_playsound(lua_State *ls)
{
const char *sf = luaL_checkstring(ls, 1);
@@ -2137,6 +2156,7 @@ static const struct luaL_reg crawl_lib[] =
{ "kbhit", crawl_kbhit },
{ "flush_input", crawl_flush_input },
{ "sendkeys", crawl_sendkeys },
+ { "process_command", crawl_process_command },
{ "playsound", crawl_playsound },
{ "runmacro", crawl_runmacro },
{ "bindkey", crawl_bindkey },