summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/settings/pickup_butcher_tool.txt9
-rw-r--r--crawl-ref/source/dat/clua/userbase.lua38
-rw-r--r--crawl-ref/source/items.cc16
3 files changed, 57 insertions, 6 deletions
diff --git a/crawl-ref/settings/pickup_butcher_tool.txt b/crawl-ref/settings/pickup_butcher_tool.txt
index 0a6e5e7f3e..3257d9967d 100644
--- a/crawl-ref/settings/pickup_butcher_tool.txt
+++ b/crawl-ref/settings/pickup_butcher_tool.txt
@@ -1,8 +1,6 @@
# Pick up a butchering weapon if we don't already have one
-# This requires ) to be in the autopickup option line
< do
-local old_ch_autopickup = ch_autopickup or function() return true end
local function can_butcher(it)
if item.name(it):find("distort", 0, true) then
return false
@@ -21,7 +19,7 @@ local function can_butcher(it)
return skill:find("Blades", 0, true) or skill == "Axes"
end
end
-function ch_autopickup(it)
+function pickup_butcher(it)
if item.class(it, true) == "weapon" then
local need_blade = true
-- Trolls and Ghouls don't need weapons to butcher things, and Mummies
@@ -42,7 +40,8 @@ function ch_autopickup(it)
end
return need_blade and not item.cursed(it) and can_butcher(it)
else
- return old_ch_autopickup(it)
+ return false
end
end
-end > \ No newline at end of file
+add_autopickup_func(pickup_butcher)
+end >
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);
}