Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mouseWidth = 0
- mouseHeight = 0
- monitor = peripheral.wrap("monitor_6")
- monitor.clear()
- monitor.setCursorPos(1,1)
- w,h=monitor.getSize()
- print(w)
- print(h)
- monitor.setBackgroundColour((colours.lime))
- monitor.setCursorPos(20,5)
- monitor.write(" North ")
- monitor.setCursorPos(28,10)
- monitor.write(" East ")
- monitor.setCursorPos(12,10)
- monitor.write(" West ")
- monitor.setCursorPos(20,15)
- monitor.write(" South ")
- monitor.setBackgroundColour((colours.lime))
- function north()
- rs.setOutput("back", true)
- sleep(1)
- os.reboot()
- end
- function east()
- rs.setOutput("right", true)
- sleep(1)
- os.reboot()
- end
- function south()
- rs.setOutput("button", true)
- sleep(1)
- os.reboot()
- end
- function west()
- rs.setOutput("left", true)
- sleep(1)
- os.reboot()
- end
- function checkClickPosition()
- if mouseWidth > 12 and mouseWidth < 28 and mouseHeight == 5 then
- north()
- elseif mouseWidth > 20 and mouseWidth < 35 and mouseHeight == 10 then
- east()
- elseif mouseWidth > 12 and mouseWidth < 28 and mouseHeight == 15 then
- south()
- elseif mouseWidth > 5 and mouseWidth < 18 and mouseHeight == 10 then
- west()
- end
- end
- repeat
- event,p1,p2,p3 = os.pullEvent()
- if event=="monitor_touch" then
- mouseWidth = p2 -- sets mouseWidth
- mouseHeight = p3 -- and mouseHeight
- checkClickPosition() -- this runs our function
- end
- until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment