autocrafting fix

This commit is contained in:
kepler155c
2018-01-26 07:19:42 -05:00
parent fcaaf87052
commit bcf08b0fe3

View File

@@ -1233,21 +1233,22 @@ function craftPage.wizard:eventHandler(event)
return UI.Wizard.eventHandler(self, event)
end
function craftPage.wizard.pags.resources:enable()
local items = listItems()
local count = tonumber(self.parent.quantity.count.value)
local recipe = Craft.findRecipe(self.item)
local ingredients = Craft.getResourceList4(recipe, items, count)
for _,v in pairs(ingredients) do
v.displayName = itemDB:getName(v)
end
self.grid:setValues(ingredients)
return UI.Window.enable(self)
end
function craftPage:eventHandler(event)
if event.type == 'cancel' then
UI:setPreviousPage()
elseif event.type == 'enable_view' and event.next then
local items = listItems()
local count = tonumber(self.wizard.pages.quantity.count.value)
local recipe = Craft.findRecipe(self.item)
local ingredients = Craft.getResourceList4(recipe, items, count)
for _,v in pairs(ingredients) do
v.displayName = itemDB:getName(v)
end
self.wizard.pages.resources.grid:setValues(ingredients)
return false
elseif event.type == 'accept' then
local key = uniqueKey(self.item)
demandCrafting[key] = Util.shallowCopy(self.item)