summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-10 02:34:06 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-10 02:34:06 +0000
commit1ef09d3a6fedddff10e68c836286415c45ce7dce (patch)
tree85656765f461563a48a4f52f35aeebee25c8d07b /crawl-ref/source
parentfaf8f98361554b28bdcd28fb4dd0bb1c9d348380 (diff)
downloadcrawl-ref-1ef09d3a6fedddff10e68c836286415c45ce7dce.tar.gz
crawl-ref-1ef09d3a6fedddff10e68c836286415c45ce7dce.zip
Restore capability of lua scripts to change autopickup behaviour so
pickup_butcher_tool.txt can work, changed so that ')' doesn't have to be in the autopickup line for it to work. Also changed so that it's easy for multiple lua functions to change autopickup without stepping on each other. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5690 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dat/clua/userbase.lua38
-rw-r--r--crawl-ref/source/items.cc16
2 files changed, 53 insertions, 1 deletions
diff --git a/crawl-ref/source/dat/clua/userbase.lua b/crawl-ref/source/dat/clua/userbase.lua
index 4131292bab..fe2dcf4d8e 100644
--- a/crawl-ref/source/dat/clua/userbase.lua
+++ b/crawl-ref/source/dat/clua/userbase.lua
@@ -10,6 +10,8 @@ chk_lua_option = { }
-- Push into this table, rather than indexing into it.
chk_lua_save = { }
+chk_force_autopickup = { }
+chk_deny_autopickup = { }
function c_save(file)
if not chk_lua_save then
@@ -75,4 +77,38 @@ function opt_boolean(optname, default)
else
return optval == "true" or optval == "yes"
end
-end \ No newline at end of file
+end
+
+function ch_force_autopickup(it, name)
+ if not chk_force_autopickup then
+ return false
+ end
+ for i = 1, #chk_force_autopickup do
+ if chk_force_autopickup[i](it, name) then
+ return true
+ end
+ end
+
+ return false
+end
+
+function add_autopickup_func(func)
+ table.insert(chk_force_autopickup, func)
+end
+
+function ch_deny_autopickup(it, name)
+ if not chk_deny_autopickup then
+ return false
+ end
+ for i = 1, #chk_deny_autopickup do
+ if chk_deny_autopickup[i](it, name) then
+ return true
+ end
+ end
+
+ return false
+end
+
+function add_no_autopickup_func(func)
+ table.insert(chk_deny_autopickup, func)
+end
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index e40aa46e59..d4ff6e63fa 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -2203,6 +2203,14 @@ static bool _is_denied_autopickup(const item_def &item, std::string &iname)
if (Options.never_pickup[i].matches(iname))
return (true);
+#ifdef CLUA_BINDINGS
+ if (clua.callbooleanfn(false, "ch_deny_autopickup", "us",
+ &item, iname.c_str()))
+ {
+ return (true);
+ }
+#endif
+
return (false);
}
@@ -2215,6 +2223,14 @@ static bool _is_forced_autopickup(const item_def &item, std::string &iname)
if (Options.always_pickup[i].matches(iname))
return (true);
+#ifdef CLUA_BINDINGS
+ if (clua.callbooleanfn(false, "ch_force_autopickup", "us",
+ &item, iname.c_str()))
+ {
+ return (true);
+ }
+#endif
+
return (false);
}