Skip to content

Commit 381a007

Browse files
committed
add-recipe: fixed pick recipe duplication
picks were already known to dwarves as diggers but were also being added as weapons by ``add-recipe all``, which caused the recipe to appear twice.
1 parent 13438c1 commit 381a007

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

add-recipe.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ local categories = {
4747
pants = {resources.pants_type, civ.equipment.pants_id, itemDefs.pants }
4848
}
4949

50+
local diggers = resources.digger_type
51+
5052
function checkKnown(known, itemType)
5153
--checks if the item with the given subtype is already known to the civ
5254
--params:
@@ -86,16 +88,16 @@ function addItems(category, exotic)
8688

8789
for _, item in ipairs(all) do
8890
subtype = item.subtype
89-
--we don't want procedural items with adjectives such as "wavy spears"
90-
--(because they don't seem to be craftable even if added)
91-
--nor do we want known items or training items (because adding training
92-
--items seems to allow them to be made out of metals)
9391
itemOk = false
9492

9593
--check if it's a training weapon
9694
t1, t2 = pcall(function () return item.flags.TRAINING == false end)
9795
training = not(not t1 or t2)
9896

97+
--we don't want procedural items with adjectives such as "wavy spears"
98+
--(because they don't seem to be craftable even if added)
99+
--nor do we want known items or training items (because adding training
100+
--items seems to allow them to be made out of metals)
99101
if (item.adjective == "" and not training and not checkKnown(known, subtype)) then
100102
itemOk = true
101103
end
@@ -104,6 +106,12 @@ function addItems(category, exotic)
104106
itemOk = false
105107
end
106108

109+
--check that the weapon we're adding is not already known to the civ as
110+
--a digging implement so picks don't get duplicated
111+
if (checkKnown(diggers, subtype)) then
112+
itemOk = false
113+
end
114+
107115
if (itemOk) then
108116
known:insert('#', subtype)
109117
table.insert(added, item)

0 commit comments

Comments
 (0)