Skip to content

Commit e10c582

Browse files
committed
Fixed quality in gui/create-item with -multi.
When -multi option is selected, gui/create-item doesn't set quality neither on stackable nor unstackable items. Fixed this quirk. No refactoring or optimizations. Just moved a variable and added code inside the createItem function.
1 parent 56f1cba commit e10c582

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

gui/create-item.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,17 @@ local function getMatFilter(itemtype)
117117
return itemTypes[df.item_type[itemtype]] or getRestrictiveMatFilter(itemtype)
118118
end
119119

120-
local function createItem(mat,itemType,quality,creator,description)
120+
local function createItem(mat,itemType,quality,creator,description,amount)
121121
local item=df.item.find(dfhack.items.createItem(itemType[1], itemType[2], mat[1], mat[2], creator))
122122
assert(item, 'failed to create item')
123123
quality = math.max(0, math.min(5, quality - 1))
124124
item:setQuality(quality)
125125
if df.item_type[itemType[1]]=='SLAB' then
126126
item.description=description
127127
end
128+
if tonumber(amount) > 1 then
129+
item:setStackSize(amount)
130+
end
128131
end
129132

130133
local function qualityTable()
@@ -207,19 +210,18 @@ function hackWish(unit)
207210
if not amountok then return end
208211
if mattype and itemtype then
209212
if df.item_type.attrs[itemtype].is_stackable then
210-
local proper_item=df.item.find(dfhack.items.createItem(itemtype, itemsubtype, mattype, matindex, unit))
211-
proper_item:setStackSize(amount)
213+
createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description,amount)
212214
else
213215
for i=1,amount do
214-
dfhack.items.createItem(itemtype, itemsubtype, mattype, matindex, unit)
216+
createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description,1)
215217
end
216218
end
217219
return true
218220
end
219221
return false
220222
else
221223
if mattype and itemtype then
222-
createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description)
224+
createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description,1)
223225
return true
224226
end
225227
return false

0 commit comments

Comments
 (0)