Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- mon = peripheral.wrap("back")
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setTextScale(2)
- function cbut(cx,cy,text, tcol, bcol)
- mon.setCursorPos(cx,cy)
- mon.setBackgroundColor(bcol)
- mon.setTextColor(tcol)
- mon.write(text)
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- end
- function save()
- shell.run("delete config")
- qsFile = fs.open("config","w")
- qsFile.writeLine(textutils.serialize(status))
- qsFile.close()
- end
- if fs.exists("config") == false then
- status = {}
- status[1] = {["Name"] = "Extruder Turm I " , ["Stats"] = "OFF",["Col"] = colors.cyan}
- status[2] = {["Name"] = "Extruder Turm II " , ["Stats"] = "OFF",["Col"] = colors.black}
- status[3] = {["Name"] = "Extruder Turm III" , ["Stats"] = "OFF",["Col"] = colors.blue}
- status[4] = {["Name"] = "Extruder Turm IV " , ["Stats"] = "OFF",["Col"] = colors.green}
- status[5] = {["Name"] = "Extruder Turm V " , ["Stats"] = "OFF",["Col"] = colors.red}
- status[6] = {["Name"] = "Extruder Turm VI " , ["Stats"] = "OFF",["Col"] = colors.lime}
- save()
- else
- rFile = fs.open("config","r")
- status = rFile.readLine(1)
- status = textutils.unserialize(status)
- rFile.close()
- end
- function writeScreen()
- cbut(2,1,status[1].Name .. ": " .. status[1].Stats, colors.black, colors.cyan)
- cbut(2,2,status[2].Name .. ": " .. status[2].Stats, colors.black, colors.gray)
- cbut(2,3,status[3].Name .. ": " .. status[3].Stats, colors.black, colors.blue)
- cbut(2,4,status[4].Name .. ": " .. status[4].Stats, colors.black, colors.green)
- cbut(2,5,status[5].Name .. ": " .. status[5].Stats, colors.black, colors.red)
- cbut(2,6,status[6].Name .. ": " .. status[6].Stats, colors.black, colors.lime)
- end
- while true do
- writeScreen()
- evt, side, x, y = os.pullEvent("monitor_touch")
- if x > 20 and x < 25 then
- if status[y].Stats == "OFF" then
- status[y].Stats = "ON "
- r = rs.getBundledOutput("front") + status[y].Col
- rs.setBundledOutput("front",r)
- save()
- elseif status[y].Stats == "ON " then
- status[y].Stats = "OFF"
- r = rs.getBundledOutput("front") - status[y].Col
- rs.setBundledOutput("front",r)
- save()
- end
- end
- end
Add Comment
Please, Sign In to add comment