Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- WarpDrive Lift Control v1 by DrPepper
- -------------------------------------------------------------------
- -------------------------------------------------------------------
- if not fs.exists("widgets_0_3.lua") then
- if not shell.run("pastebin get iA6LZxX7 widgets_0_3.lua") then
- error("Unable to get the dependency from Pastebin")
- end
- end
- if not fs.exists("utils_0_2.lua") then
- if not shell.run("pastebin get dGWjEaL5 utils_0_2.lua") then
- error("Unable to get the dependency from Pastebin")
- end
- end
- local Widgets = require("widgets_0_3")
- local Utils = require("utils_0_2")
- Widgets.Logger.enable("ERROR")
- Widgets.Logger.enable("DEBUG")
- Utils.PeripheralManager.SetLogger(Widgets.Logger)
- Utils.PeripheralManager.Init()
- --find peripherals
- local pMon = Utils.PeripheralManager.GetPeripheralByParamAndType(
- "monitor", true, "monitor")
- local pLiftL = Utils.PeripheralManager.GetPeripheralByParamAndType(
- "warpdriveLift", true, "left")
- local pLiftR = Utils.PeripheralManager.GetPeripheralByParamAndType(
- "warpdriveLift", true, "right")
- local mainMonitorWidget = Widgets.MonitorWidget:new()
- mainMonitorWidget.name = "mainMonitorWidget"
- local monBtnL = Widgets.Button:new()
- if pMon and pMon.wrapped then
- mainMonitorWidget:init(pMon.wrapped)
- monBtnL:init(mainMonitorWidget, 1, 1, 5, 1, true)
- monBtnL.caption = "< "
- if pLiftL.wrapped then
- monBtnL.caption = monBtnL.caption..pLiftL.wrapped.mode()
- end
- end
- local mainWidget = Widgets.Widget:new()
- mainWidget:init(nil, 1, 1, 51, 19, true)
- mainWidget.name = "mainWidget"
- --Tabs
- local tabWidget = Widgets.Tabs:new()
- tabWidget:init(mainWidget, 1, 1, 51, 18, true)
- tabWidget.name = "tabWidget"
- --Text input
- local textInput = Widgets.InputLine:new()
- textInput:init(mainWidget, 1, 19, 43, 1, true)
- -- Tab 1 -- User manual
- local tab1 = tabWidget:addTab(" USAGE ")
- local manLabelWidget = Widgets.Label:new()
- manLabelWidget:init(tab1, 1, 1, 51, 17)
- manLabelWidget.text = "\n WarpDrive lift controller v1\n \n Requires the following peripherals:\n \n monitor (advanced): \"monitor\" = true\n warpdriveLift: \"left\" = true\n warpdriveLift: \"right\" = true\n \n Make sure to save these properties to peripheral.cfg"
- -- Tab 2 -- Peripheral manager from Utils
- local tabPerMan2 = tabWidget:addTab(" PERIPHERALS ")
- Utils.CreatePeripheralManagerTab(tabPerMan2, textInput)
- tabWidget:selectTab(" USAGE ")
- mainWidget:draw()
- mainMonitorWidget:draw()
- local function CoroutineUserInput()
- while true do
- local p1, p2, p3, p4, p5 = os.pullEvent()
- if p1 == "mouse_click"
- or p1 == "mouse_scroll"
- or p1 == "mouse_up" then
- mainWidget:processEvent(p1, p2, p3, p4, p5)
- end
- if p1 == "monitor_touch" then
- mainMonitorWidget:processEvent(p1, p2, p3, p4, p5)
- end
- end
- end
- parallel.waitForAny(CoroutineUserInput,
- Utils.PeripheralManager.ManagerCoroutine
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement