From 548c54e8b1e48dcc9c69685933cd40bc8c0102da Mon Sep 17 00:00:00 2001 From: aria Date: Tue, 8 Jul 2025 22:22:21 +1000 Subject: [PATCH] feat: add clicker --- README.md | 10 ++++++++++ clicker/clicker.lua | 38 ++++++++++++++++++++++++++++++++++++++ clicker/count.txt | 1 + 3 files changed, 49 insertions(+) create mode 100644 clicker/clicker.lua create mode 100644 clicker/count.txt diff --git a/README.md b/README.md index 5b2f4f9..af829f6 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,16 @@ Just a bunch of computer craft scripts I guess? If I write anything I'll put it here +## Scripts + +### clicker + +clicker.lua is a simple "cookie clicker like", funny number go up! + +It gets a screen on the left of the computer (This is poorly writen but we ignore that~) and displays the number stored in `count.txt`, every 10 clicks it writes into that file with an updated count. + +it reads `count.txt` every launch so the most progress you can lose is `9`. + ## Mirrors - Main: [https://git.aria.coffee/aria/computer-craft-scripts](https://git.aria.coffee/aria/computer-craft-scripts) diff --git a/clicker/clicker.lua b/clicker/clicker.lua new file mode 100644 index 0000000..cb6242c --- /dev/null +++ b/clicker/clicker.lua @@ -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 diff --git a/clicker/count.txt b/clicker/count.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/clicker/count.txt @@ -0,0 +1 @@ +0