Advertisement
glitchdetector

Monitor Test

Oct 14th, 2023 (edited)
969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. local monitor = peripheral.wrap("top")
  2.  
  3. local n = 0
  4. while true do
  5.     local w, h = monitor.getSize()
  6.     monitor.clear()
  7.     monitor.setCursorPos(1, h)
  8.     monitor.blit("-", "0", "e")
  9.     monitor.setCursorPos(w, h)
  10.     monitor.blit("+", "0", "d")
  11.  
  12.     monitor.setCursorPos(1, 1)
  13.     monitor.write("COUNTER")
  14.  
  15.     monitor.setCursorPos(1, 2)
  16.     monitor.write(("%.0f"):format(n))
  17.  
  18.     local event, side, xPos, yPos = os.pullEvent("monitor_touch")
  19.     if xPos == 1 and yPos == h then
  20.         n = n - 1
  21.     elseif xPos == w and yPos == h then
  22.         n = n + 1
  23.     end
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement