feat: add clicker
This commit is contained in:
parent
6edb6edc17
commit
548c54e8b1
3 changed files with 49 additions and 0 deletions
38
clicker/clicker.lua
Normal file
38
clicker/clicker.lua
Normal 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
|
1
clicker/count.txt
Normal file
1
clicker/count.txt
Normal file
|
@ -0,0 +1 @@
|
|||
0
|
Loading…
Add table
Add a link
Reference in a new issue