computer-craft-scripts/clicker/clicker.lua
2025-07-08 22:22:21 +10:00

38 lines
741 B
Lua

m = peripheral.wrap("left")
m.setTextScale(2)
x = 0
file = io.input("count.txt")
if file ~= nil then
local file_contents = io.read()
x = tonumber(file_contents)
end
m.clear()
m.setCursorPos(1,1)
m.write(x)
while true do
local eventData = {os.pullEvent()}
local event = eventData[1]
local res = false
if event == "mouse_click" or event == "monitor_touch" then
res = true
elseif event == "redstone" then
res = redstone.getInput("front")
end
if res then
x = x + 1
m.setCursorPos(1,1)
m.write(x)
if x % 10 == 0 then
io.output("count.txt")
io.write(tostring(x))
end
end
end