ignore nbt for crafting

This commit is contained in:
kepler155c@gmail.com
2018-12-30 06:16:09 -05:00
parent d4b8ffb978
commit b726e5011f
3 changed files with 31 additions and 16 deletions

View File

@@ -26,14 +26,9 @@ local craftPage = UI.Page {
x = 6, y = 4,
value = 'Eject',
},
eject = UI.Chooser {
eject = UI.Checkbox {
x = 15, y = 4, width = 7,
value = true,
nochoice = 'No',
choices = {
{ name = 'Yes', value = true },
{ name = 'No', value = false },
},
},
},
resources = UI.Window {

View File

@@ -4,11 +4,12 @@ local Milo = require('milo')
local UI = require('ui')
local Util = require('util')
local colors = _G.colors
local turtle = _G.turtle
local context = Milo:getContext()
local function learnRecipe()
local function learnRecipe(ignoreNBT)
local ingredients = Milo:getTurtleInventory()
if not ingredients then
@@ -77,13 +78,15 @@ local function learnRecipe()
end
if not recipe then
_debug(results)
_debug(newRecipe)
error('Failed - view system log')
return false, 'Unknown error'
end
newRecipe.count = recipe.count
if ignoreNBT then
recipe.nbtHash = nil
end
local key = Milo:uniqueKey(recipe)
if recipe.maxCount ~= 64 then
newRecipe.maxCount = recipe.maxCount
@@ -92,6 +95,9 @@ local function learnRecipe()
if ingredient.maxDamage > 0 then
-- ingredient.damage = '*' -- I don't think this is right
end
if ignoreNBT then
ingredient.nbtHash = nil
end
ingredients[k] = Milo:uniqueKey(ingredient)
end
@@ -108,16 +114,30 @@ local pages = {
turtleCraft = UI.Window {
index = 2,
validFor = 'Turtle Crafting',
notice = UI.TextArea {
x = 2, ex = -2, y = 2, ey = -2,
value =
[[Place recipe in turtle!]],
notice = UI.Text {
x = 2, y = 2,
textColor = colors.yellow,
value = 'Place recipe in turtle',
},
ignoreNBT = UI.Checkbox {
x = 3, y = 4,
help = 'Ignore damage of item',
value = true,
},
text = UI.Text {
x = 7, y = 4,
value = 'Ignore NBT (recommended)',
},
ignoreInfo = UI.TextArea {
x = 2, ex = -2, y = 6, ey = -2,
textColor = colors.yellow,
value = 'Some items contain unique NBT information. This information can be ignored for most items.',
},
},
}
function pages.turtleCraft:validate()
local recipe, msg = learnRecipe(self)
local recipe, msg = learnRecipe(self, self.ignoreNBT.value)
if recipe then
local displayName = itemDB:getName(recipe)

View File

@@ -331,7 +331,7 @@ local function equip(side, item)
end
local function scan()
equip('left', 'plethora:module')
equip('left', 'plethora:module:2')
local blocks = peripheral.call('left', 'scan')
equip('left', 'minecraft:diamond_pickaxe')
local throttle = Util.throttle()