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.
develop
Matsor Browncoat 2016-05-01 19:50:03 +02:00
parent 208eb6f452
commit ce3c9d06a0
1 changed files with 7 additions and 5 deletions

@ -117,7 +117,7 @@ local function getMatFilter(itemtype)
return itemTypes[df.item_type[itemtype]] or getRestrictiveMatFilter(itemtype)
end
local function createItem(mat,itemType,quality,creator,description)
local function createItem(mat,itemType,quality,creator,description,amount)
local item=df.item.find(dfhack.items.createItem(itemType[1], itemType[2], mat[1], mat[2], creator))
assert(item, 'failed to create item')
quality = math.max(0, math.min(5, quality - 1))
@ -125,6 +125,9 @@ local function createItem(mat,itemType,quality,creator,description)
if df.item_type[itemType[1]]=='SLAB' then
item.description=description
end
if tonumber(amount) > 1 then
item:setStackSize(amount)
end
end
local function qualityTable()
@ -207,11 +210,10 @@ function hackWish(unit)
if not amountok then return end
if mattype and itemtype then
if df.item_type.attrs[itemtype].is_stackable then
local proper_item=df.item.find(dfhack.items.createItem(itemtype, itemsubtype, mattype, matindex, unit))
proper_item:setStackSize(amount)
createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description,amount)
else
for i=1,amount do
dfhack.items.createItem(itemtype, itemsubtype, mattype, matindex, unit)
createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description,1)
end
end
return true
@ -219,7 +221,7 @@ function hackWish(unit)
return false
else
if mattype and itemtype then
createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description)
createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description,1)
return true
end
return false