glitchdetector icon

Monitor Test

glitchdetector | PRO | 10/14/23 07:36:49 PM UTC (Edited) | 0 ⭐ | 1243 👁️ | Never ⏰ | []
Lua |

580 B

|

None

|

0 👍

/

0 👎

local monitor = peripheral.wrap("top")
 
local n = 0
while true do
    local w, h = monitor.getSize()
    monitor.clear()
    monitor.setCursorPos(1, h)
    monitor.blit("-", "0", "e")
    monitor.setCursorPos(w, h)
    monitor.blit("+", "0", "d")
 
    monitor.setCursorPos(1, 1)
    monitor.write("COUNTER")
 
    monitor.setCursorPos(1, 2)
    monitor.write(("%.0f"):format(n))
 
    local event, side, xPos, yPos = os.pullEvent("monitor_touch")
    if xPos == 1 and yPos == h then
        n = n - 1
    elseif xPos == w and yPos == h then
        n = n + 1
    end
end

Comments