summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
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);
}