fuzzy recipe ingredients
This commit is contained in:
@@ -82,7 +82,7 @@ end
|
||||
function Craft.loadRecipes()
|
||||
Craft.recipes = { }
|
||||
|
||||
Util.merge((Util.readTable(fs.combine(RECIPES_DIR, 'minecraft.db')) or { }).recipes)
|
||||
Util.merge(Craft.recipes, (Util.readTable(fs.combine(RECIPES_DIR, 'minecraft.db')) or { }).recipes)
|
||||
|
||||
local config = Util.readTable('usr/config/recipeBooks.db') or { }
|
||||
for _, book in pairs(config) do
|
||||
@@ -157,8 +157,23 @@ local function makeRecipeKey(item)
|
||||
return table.concat({ item.name, item.damage or 0, item.nbtHash }, ':')
|
||||
end
|
||||
|
||||
function Craft.findRecipe(item)
|
||||
function Craft.findRecipe(key)
|
||||
if type(key) ~= 'string' then
|
||||
key = itemDB:makeKey(key)
|
||||
end
|
||||
|
||||
local item = itemDB:splitKey(key)
|
||||
if item.damage then
|
||||
return Craft.recipes[makeRecipeKey(item)]
|
||||
end
|
||||
|
||||
-- handle cases where the request is like : IC2:reactorVent:*
|
||||
for _,recipe in pairs(Craft.recipes) do
|
||||
if item.name == recipe.name and
|
||||
(not item.nbtHash or recipe.nbtHash == item.nbtHash) then
|
||||
return recipe
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- determine the full list of ingredients needed to craft
|
||||
|
||||
@@ -63,7 +63,6 @@ local page = UI.Page {
|
||||
accelerators = {
|
||||
q = 'quit',
|
||||
space = 'grid_select',
|
||||
t = 'terminate',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -104,16 +103,19 @@ end
|
||||
|
||||
function page:eventHandler(event)
|
||||
if event.type == 'grid_select' then
|
||||
local recipes = self.grid:getSelected()
|
||||
recipes.enabled = not recipes.enabled
|
||||
local book = self.grid:getSelected()
|
||||
book.enabled = not book.enabled
|
||||
self.info:draw()
|
||||
self.grid:draw()
|
||||
self:save()
|
||||
|
||||
elseif event.type == 'grid_focus_row' then
|
||||
self.info:draw()
|
||||
|
||||
elseif event.type == 'quit' then
|
||||
UI:exitPullEvents()
|
||||
end
|
||||
|
||||
UI.Page.eventHandler(self, event)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user