Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function screen()
- term.clear()
- term.setCursorPos(1,1)
- print(" compteur ")
- print(" dirt : "..dirt)
- print(" cobble : "..cobble)
- print(" coal : "..coal)
- end
- function counting()
- rsInput = rs.getBundledInput("top")
- if colors.test(rsInput, colors.brown) == true then
- dirt = dirt + 1
- end
- if colors.test(rsInput, colors.gray) == true then
- cobble = cobble + 1
- end
- if colors.test(rsInput, colors.black) == true then
- coal = coal + 1
- end
- count = fs.open("counter.txt", "w")
- count.writeLine(dirt)
- count.writeLine(cobble)
- count.writeLine(coal)
- count.close()
- screen()
- loop()
- end
- function loop()
- while true do
- event = os.pullEvent()
- if event == "redstone" then
- counting()
- end
- end
- end
- if fs.exists("counter.txt") == false then
- count = fs.open("counter.txt", "w")
- dirt = 0
- cobble = 0
- coal = 0
- count.writeLine(dirt)
- count.writeLine(cobble)
- count.writeLine(coal)
- count.close()
- end
- count = fs.open("counter.txt", "r")
- dirt = tonumber(count.readLine())
- cobble = tonumber(count.readLine())
- coal = tonumber(count.readLine())
- count.close()
- screen()
- loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement