fuzzy recipe ingredients
This commit is contained in:
@@ -82,7 +82,7 @@ end
|
|||||||
function Craft.loadRecipes()
|
function Craft.loadRecipes()
|
||||||
Craft.recipes = { }
|
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 { }
|
local config = Util.readTable('usr/config/recipeBooks.db') or { }
|
||||||
for _, book in pairs(config) do
|
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 }, ':')
|
return table.concat({ item.name, item.damage or 0, item.nbtHash }, ':')
|
||||||
end
|
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)]
|
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
|
end
|
||||||
|
|
||||||
-- determine the full list of ingredients needed to craft
|
-- determine the full list of ingredients needed to craft
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ local page = UI.Page {
|
|||||||
accelerators = {
|
accelerators = {
|
||||||
q = 'quit',
|
q = 'quit',
|
||||||
space = 'grid_select',
|
space = 'grid_select',
|
||||||
t = 'terminate',
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,16 +103,19 @@ end
|
|||||||
|
|
||||||
function page:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
if event.type == 'grid_select' then
|
if event.type == 'grid_select' then
|
||||||
local recipes = self.grid:getSelected()
|
local book = self.grid:getSelected()
|
||||||
recipes.enabled = not recipes.enabled
|
book.enabled = not book.enabled
|
||||||
self.info:draw()
|
self.info:draw()
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
self:save()
|
self:save()
|
||||||
|
|
||||||
elseif event.type == 'grid_focus_row' then
|
elseif event.type == 'grid_focus_row' then
|
||||||
self.info:draw()
|
self.info:draw()
|
||||||
|
|
||||||
elseif event.type == 'quit' then
|
elseif event.type == 'quit' then
|
||||||
UI:exitPullEvents()
|
UI:exitPullEvents()
|
||||||
end
|
end
|
||||||
|
|
||||||
UI.Page.eventHandler(self, event)
|
UI.Page.eventHandler(self, event)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user