Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mouseWidth = 0
- mouseHeight = 0
- p = peripheral.wrap("back")
- monitor = peripheral.wrap("top")
- monitor.clear()
- monitor.setTextScale(0.5)
- monitor.setCursorPos(1,1)
- monitor.write("Setpoint:")
- monitor.setCursorPos(1,2)
- monitor.write("Pressure:")
- monitor.setCursorPos(1,1)
- w,h=monitor.getSize()
- print(w)
- print(h)
- monitor.setBackgroundColour((colours.lime))
- monitor.setCursorPos(10,1)
- monitor.write("1")
- monitor.setCursorPos(11,1)
- monitor.write("2")
- monitor.setCursorPos(12,1)
- monitor.write("3")
- monitor.setCursorPos(13,1)
- monitor.write("4")
- monitor.setCursorPos(14,1)
- monitor.write("5")
- monitor.setBackgroundColour((colours.black))
- function checkClickPosition()
- if mouseWidth == 10 and mouseHeight == 1 then
- setpoint=1
- print(setpoint)
- elseif mouseWidth == 11 and mouseHeight == 1 then
- setpoint=2
- print(setpoint)
- elseif mouseWidth == 12 and mouseHeight == 1 then
- setpoint=3
- print(setpoint)
- elseif mouseWidth == 13 and mouseHeight == 1 then
- setpoint=4
- print(setpoint)
- elseif mouseWidth == 14 and mouseHeight == 1 then
- setpoint=5
- print(setpoint)
- end -- ends the if loop
- end -- ends the function
- while true do
- event,p1,p2,p3 = os.pullEvent()
- while setpoint<1 then
- if event=="monitor_touch" then
- mouseWidth = p2 -- sets mouseWidth
- mouseHeight = p3 -- and mouseHeight
- checkClickPosition() -- this runs our function
- end
- end
- print("while end")
- x = p.getPressure()
- print("pressure get")
- y = setpoint
- y1 = setpoint+0.45
- term.setCursorPos(1,3)
- monitor.setCursorPos(1,3)
- term.write(x)
- monitor.write(x)
- sleep(1)
- term.clearLine()
- monitor.clearLine()
- if x < y then
- rs.setOutput("right",true)
- rs.setOutput("back",false)
- elseif x > y1 or x>4.9 then
- rs.setOutput("back",true)
- elseif x > y or x>4.9 then
- rs.setOutput("right",false)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement