diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-09-18 15:08:25 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-09-18 15:08:25 +0000 |
commit | a4d4f3ecccb29c3f5fc1ce55579119106c399911 (patch) | |
tree | 5677ea04b4dfdadd961c01ba3baf7502f8d6e0d0 /stone_soup/crawl-ref/source/lua/base.lua | |
parent | 571501e1135989d3b9dc44e3d332562a7cf78b35 (diff) | |
download | crawl-ref-a4d4f3ecccb29c3f5fc1ce55579119106c399911.tar.gz crawl-ref-a4d4f3ecccb29c3f5fc1ce55579119106c399911.zip |
Updated stone_soup-0.1b1 tag to include fix for Poison Arrow of Doom.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/tags/stone_soup-0.1b1@49 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'stone_soup/crawl-ref/source/lua/base.lua')
-rw-r--r-- | stone_soup/crawl-ref/source/lua/base.lua | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/stone_soup/crawl-ref/source/lua/base.lua b/stone_soup/crawl-ref/source/lua/base.lua new file mode 100644 index 0000000000..db7b15afda --- /dev/null +++ b/stone_soup/crawl-ref/source/lua/base.lua @@ -0,0 +1,74 @@ +--------------------------------------------------------------------------- +-- base.lua: +-- Base Lua definitions that other Lua scripts rely on. +-- NOTE: Other Lua scripts may demonstrate buggy behaviour if you do +-- not source this file. If you're using no Lua scripts at all, you +-- needn't source base.lua. +-- +-- To use this, add this line to your init.txt: +-- lua_file = lua/base.lua +--------------------------------------------------------------------------- + +-- Lua global data +chk_interrupt_macro = { } +chk_interrupt_activity = { } +chk_lua_option = { } + +-- Push into this table, rather than indexing into it. +chk_lua_save = { } + +function c_save(file) + if not chk_lua_save then + return + end + + for i, fn in ipairs(chk_lua_save) do + fn(file) + end +end + +-- This function returns true to tell Crawl not to process the option further +function c_process_lua_option(key, val) + if chk_lua_option and chk_lua_option[key] then + return chk_lua_option[key](key, val) + end + return false +end + +function c_interrupt_macro(iname, cause, extra) + -- If some joker undefined the table, stop all macros + if not chk_interrupt_macro then + return true + end + + -- Maybe we don't know what macro is running? Kill it to be safe + -- We also kill macros that don't add an entry to chk_interrupt_macro. + if not c_macro_name or not chk_interrupt_macro[c_macro_name] then + return true + end + + return chk_interrupt_macro[c_macro_name](iname, cause, extra) +end + +-- Notice that c_interrupt_activity defaults to *false* whereas +-- c_interrupt_macro defaults to *true*. This is because "false" really just +-- means "go ahead and use the default logic to kill this activity" here, +-- whereas false is interpreted as "no, don't stop this macro" for +-- c_interrupt_macro. +-- +-- If c_interrupt_activity, or one of the individual hooks wants to ensure that +-- the activity continues, it must return *nil* (make sure you know what you're +-- doing when you return nil!). +function c_interrupt_activity(aname, iname, cause, extra) + -- If some joker undefined the table, bail out + if not chk_interrupt_activity then + return false + end + + -- No activity name? Bail! + if not aname or not chk_interrupt_activity[aname] then + return false + end + + return chk_interrupt_activity[aname](iname, cause, extra) +end |