Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("button")
- mon = peripheral.wrap("left")
- mon.clear()
- redstone.setOutput("right",false)
- --Variables
- local comp = peripheral.wrap("right")
- local danger = comp.getDangerPressure()
- local pressure = comp.getPressure()
- --Functions
- function fillTable()
- button.setTable("ON",on,2,8,2,4)
- button.setTable("OFF",off,11,17,2,4)
- button.screen()
- end
- function on()
- if rdstnlvl == false then
- button.toggleButton("ON")
- redstone.setOutput("right",true)
- button.toggleButton("OFF")
- print("ON")
- end
- end
- function off()
- if rdstnlvl == true then
- button.toggleButton("OFF")
- redstone.setOutput("right",false)
- button.toggleButton("ON")
- print("OFF")
- end
- end
- function getClick()
- event,side,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- function newLine()
- local x,y = mon.getCursorPos()
- mon.setCursorPos(1,y+1)
- mon.clearLine()
- end
- function getRedstoneLevel()
- rdstnlvl = redstone.getOutput("right")
- end
- function pressureReport()
- mon.setCursorPos(1,7)
- getPressureLevel()
- mon.write(pressure)
- newLine()
- getRedstoneLevel()
- mon.write(rdstnlvl)
- end
- function getPressureLevel()
- pressure = comp.getPressure()
- end
- --Main
- button.heading("Pressure Control")
- fillTable()
- button.toggleButton("OFF")
- while true do
- if pressure >= danger-0.5 then
- off()
- pressureReport()
- else
- on()
- pressureReport()
- end
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement