Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- m = peripheral.wrap("top")
- m.setTextScale(0.5)
- mid = 1352
- function updatetime(time)
- tfile = fs.open("time","w")
- tfile.write(time)
- tfile.close()
- end
- function gettime()
- tfile = fs.open("time","r")
- time = tfile.readAll()
- tfile.close()
- return tonumber(time)
- end
- function updatecname(name)
- cnfile = fs.open("cname","w")
- cnfile.write(name)
- cnfile.close()
- end
- function getcname()
- cnfile = fs.open("cname","r")
- cn = cnfile.readAll()
- cnfile.close()
- return cn
- end
- color = {}
- color.vc1 = colors.yellow
- color.vc2 = colors.white
- function writemon()
- term.redirect(m)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(color.vc1)
- print("Player:")
- term.setTextColor(color.vc2)
- print(getcname())
- term.setTextColor(color.vc1)
- print("Remaining Time:")
- term.setTextColor(color.vc2)
- print(gettime().." sec.")
- size = {term.getSize()}
- term.setCursorPos(1,size[2])
- term.setTextColor(color.vc1)
- term.write("Slave ID: ")
- term.setTextColor(color.vc2)
- term.write(os.getComputerID())
- term.restore()
- end
- if not fs.exists("time") then
- updatetime(0)
- end
- if not fs.exists("cname") then
- updatecname("No Player!")
- end
- ctime = gettime()
- writemon()
- os.startTimer(1)
- while true do
- evnt = {os.pullEvent()}
- if evnt[1] == "rednet_message" then
- for i = 1,#evnt do
- print(evnt[i])
- end
- print("EOF")
- if evnt[3]:find(":") then
- args = {}
- for arg in string.gmatch(evnt[3], '([^:]+)') do
- table.insert(args,arg)
- end
- if evnt[2] == mid then
- if args[1] == "ms" and args[2] == "gs" then
- rednet.send(evnt[2],os.getComputerID())
- elseif args[1] == "ms" then
- if args[2] == tostring(os.getComputerID()) then
- if args[3] == "break" then
- turtle.dig()
- elseif args[3] == "place" then
- turtle.place()
- elseif args[3] == "rn" then
- print("I have been renamed to: "..args[4])
- updatecname(args[4])
- writemon()
- elseif args[3] == "stime" then
- updatetime(args[4])
- end
- end
- end
- end
- end
- elseif evnt[1] == "timer" then
- if gettime() ~= 0 then
- updatetime(gettime()-1)
- turtle.place()
- else
- turtle.dig()
- end
- os.startTimer(1)
- print("Timer started")
- writemon()
- end
- end
Add Comment
Please, Sign In to add comment