feat: add clicker

This commit is contained in:
aria 2025-07-08 22:22:21 +10:00
parent 6edb6edc17
commit 548c54e8b1
Signed by: aria
SSH key fingerprint: SHA256:WqtcVnDMrv1lnUlNah5k31iywFUI/DV+5yHzCTO4Vds
3 changed files with 49 additions and 0 deletions

38
clicker/clicker.lua Normal file
View file

@ -0,0 +1,38 @@
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