milo: simplify learn types + monitor resize

This commit is contained in:
kepler155c@gmail.com
2018-12-04 18:49:01 -05:00
parent e90e6cebdd
commit fff04ec01a
18 changed files with 225 additions and 305 deletions

View File

@@ -104,30 +104,19 @@ local function learnRecipe()
return recipe
end
local turtleLearnWizard = UI.Page {
titleBar = UI.TitleBar { title = 'Learn a crafting recipe' },
wizard = UI.Wizard {
y = 2, ey = -3,
pages = {
confirmation = UI.Window {
index = 1,
notice = UI.TextArea {
x = 2, ex = -2, y = 2, ey = -2,
value =
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!]],
},
},
},
},
notification = UI.Notification { },
}
function turtleLearnWizard:disable()
Milo:resumeCrafting({ key = 'gridInUse' })
UI.Page.disable(self)
end
function turtleLearnWizard.wizard.pages.confirmation:validate()
function pages.turtleCraft:validate()
local recipe, msg = learnRecipe(self)
if recipe then
@@ -139,18 +128,8 @@ function turtleLearnWizard.wizard.pages.confirmation:validate()
})
return true
else
turtleLearnWizard.notification:error(msg)
self:emit({ type = 'general_error', message = msg })
end
end
function turtleLearnWizard:eventHandler(event)
if event.type == 'cancel' then
turtle.emptyInventory()
UI:setPage('listing')
else
return UI.Page.eventHandler(self, event)
end
return true
end
context.learnTypes['Turtle crafting'] = turtleLearnWizard
UI:getPage('learnWizard').wizard:add(pages)