blob: 29bac13e3ed2d5b815292538eff9a1c188ad81ea (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
---------------------------------------------------------------------------
-- pickup.lua:
-- Pick up a butchering weapon if we don't already have one.
--
-- To use this, add this line to your init.txt:
-- lua_file = lua/pickup.lua
---------------------------------------------------------------------------
local function can_butcher(it, name)
-- Item can't be used to cut meat.
if not item.can_cut_meat(it) then
return false
end
-- If we're already wielding a weapon capable of butchering, okay.
if item.equipped(it) then
return true
end
-- Don't make the user wield a known cursed weapon.
if item.cursed(it) then
return false
end
-- Nor a known distortion weapon.
if name:find("distort", 0, true) then
return false
end
-- Else we're good.
return true
end
function pickup_butcher(it, name)
-- If you can butcher with your claws you don't need a butchering tool.
if you.has_claws() > 0 then
return false
end
-- Same if you don't ever need to butcher corpses.
if not you.can_consume_corpses() and not you.god_likes_butchery() then
return false
end
-- Can this item even be used for butchering?
if not can_butcher(it, name) then
return false
end
-- Do we already have a butchering tool?
for _, inv_it in pairs(item.inventory()) do
if can_butcher(inv_it, item.name(inv_it)) then
return false
end
end
return true
end
add_autopickup_func(pickup_butcher)
|