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