Files
opus-apps/milo/plugins/item/resetTab.lua
kepler155c@gmail.com ef0886ec85 wizard and tab rework
2020-04-26 19:39:28 -06:00

56 lines
1.1 KiB
Lua

local Craft = require('milo.craft2')
local Milo = require('milo')
local UI = require('opus.ui')
local Util = require('opus.util')
local colors = _G.colors
local context = Milo:getContext()
local resetTab = UI.Tab {
title = 'Reset',
index = 5,
noFill = true,
textArea = UI.TextArea {
y = 2, ey = 6,
textColor = colors.yellow,
value = [[ Warning!
This will clear all setting,
recipe, and machine for this item.]]
},
resetButton = UI.Button {
x = 17, y = 7,
event = 'reset',
text = 'Reset',
help = 'Clear recipe and all settings',
},
}
function resetTab:setItem(item)
self.item = item
end
function resetTab:eventHandler(event)
if event.type == 'reset' then
if context.userRecipes[self.item.key] then
Milo:updateRecipe(self.item.key, nil)
end
if context.resources[self.item.key] then
context.resources[self.item.key] = nil
Milo:saveResources()
end
if Craft.machineLookup[self.item.key] then
Craft.machineLookup[self.item.key] = nil
Util.writeTable(Craft.MACHINE_LOOKUP, Craft.machineLookup)
end
UI:setPreviousPage()
return true
end
end
return { itemTab = resetTab }