Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local switchGrind = "1"
- function readData()
- h = fs.open("data", "r")
- switchGrind = h.readLine() -- First Line: Grinder State (ON/OFF)
- h.close()
- end
- function saveData()
- h = fs.open("data", "w")
- h.writeLine(switchGrind)
- h.close()
- end
- function updateRs()
- local c = 0
- if switchGrind == "0" then
- c = c + colors.white
- end
- rs.setBundledOutput("bottom", c)
- end
- function display()
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- term.clearLine()
- term.setCursorPos(11,1)
- print "FACTORY CONTROL"
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,3)
- print "Grinder"
- term.setBackgroundColor(colors.white)
- term.setCursorPos(12,3)
- if switchGrind == "1" then
- term.setTextColor(colors.green)
- print "ON "
- else
- term.setTextColor(colors.red)
- print "OFF"
- end
- end
- if fs.exists("data") then
- readData()
- end
- display()
- while true do
- local e, p1, p2, p3 = os.pullEvent()
- if e == "mouse_click" then -- on mouse click
- if p3 == 3 and p2 >= 11 then -- grinder toggled
- if switchGrind == "1" then
- switchGrind = "0"
- else
- switchGrind = "1"
- end
- updateRs()
- saveData()
- display()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement