summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/delay.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/delay.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/delay.cc')
-rw-r--r--crawl-ref/source/delay.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index b8752d97d0..638897114b 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -631,6 +631,12 @@ static void _xom_check_corpse_waste()
xom_is_stimulated(64 + (191 * food_need / 6000));
}
+void clear_macro_process_key_delay()
+{
+ if (current_delay_action() == DELAY_MACRO_PROCESS_KEY)
+ _pop_delay();
+}
+
void handle_delay( void )
{
if (!you_are_delayed())
@@ -638,6 +644,10 @@ void handle_delay( void )
delay_queue_item &delay = you.delay_queue.front();
+ // If a Lua macro wanted Crawl to process a key normally, early exit.
+ if (delay.type == DELAY_MACRO_PROCESS_KEY)
+ return;
+
if (!delay.started)
{
switch (delay.type)
@@ -1516,7 +1526,8 @@ void run_macro(const char *macroname)
}
else
{
- start_delay(DELAY_MACRO, 1);
+ if (!you_are_delayed())
+ start_delay(DELAY_MACRO, 1);
}
#else
stop_delay();
@@ -1854,7 +1865,7 @@ static const char *delay_names[] =
"jewellery_on", "memorise", "butcher", "bottle_blood", "offer_corpse",
"weapon_swap", "passwall", "drop_item", "multidrop", "ascending_stairs",
"descending_stairs", "recite", "run", "rest", "travel", "macro",
- "interruptible", "uninterruptible"
+ "macro_process_key", "interruptible", "uninterruptible"
};
// Gets a delay given its name.