Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local xs = 7
- local xm = 4
- local xh = 1
- local y = 1
- local monitor = peripheral.wrap("left")
- local m = 33
- local h = 5
- local c = 20
- local logic = 1
- if not fs.exists("status") then
- local file = io.open("status", "w")
- file:write()
- file:close()
- end
- function write(path, text)
- local file = assert(io.open(path, "w"))
- file:write(text)
- file:close()
- end
- function writeFromTable(path, t)
- local text = ""
- for _, line in pairs(t) do
- text = text..line.."/n"
- end
- write(path, text)
- end
- function getTable(path)
- if fs.exists(path) then
- local file = io.open(path, "r")
- local lines = {}
- local u = 1
- local line = file:read("*1")
- while line ~= nil do
- lines[i] = line
- line = file:read("*1")
- u = u + 1
- end
- file:close()
- return lines
- end
- return {}
- end
- function w(path, n, text)
- local lines = getTable(path)
- lines[n] = text
- writeFromTable(path, lines)
- end
- local config = getTable("status")
- h = tonumber(string.sub(config[1], 1))
- m = tonumber(string.sub(config[2], 1))
- c = tonumber(string.sub(config[3], 1))
- while logic==1 do
- rs.setOutput("top",true)
- for i = 60,0,-1 do
- c = c-1
- monitor.clear()
- monitor.setCursorPos(3,1)
- monitor.write(":")
- monitor.setCursorPos(6,1)
- monitor.write(":")
- monitor.setCursorPos(xs,y)
- monitor.write(tostring(c))
- monitor.setCursorPos(xm,y)
- monitor.write(tostring(m))
- monitor.setCursorPos(xh,y)
- monitor.write(tostring(h))
- sleep(1)
- w("status", 1,h)
- w("status", 2,m)
- w("status", 3,c)
- if c == 0 then
- c = 60
- m = m-1
- monitor.clear()
- monitor.setCursorPos(3,1)
- monitor.write(":")
- monitor.setCursorPos(xs,y)
- monitor.write(tostring(0))
- monitor.setCursorPos(xm,y)
- monitor.write(tostring(m))
- monitor.setCursorPos(xh,y)
- monitor.write(tostring(h))
- end
- if m == 0 then
- m = 60
- h = h-1
- monitor.clear()
- monitor.setCursorPos(6,1)
- monitor.write(":")
- monitor.setCursorPos(xs,y)
- monitor.write(tostring(0))
- monitor.setCursorPos(xm,y)
- monitor.write(tostring(m))
- monitor.setCursorPos(xh,y)
- monitor.write(tostring(h))
- end
- if h ==0 then
- if m == 0 then
- if c == 0 then
- logic = 0
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment