Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- server = 000
- side = "top"
- chest = false
- function round(number)
- if (number % 1) < 0.5 then
- return math.floor(number)
- else
- return math.ceil(number)
- end
- end
- counter = 0
- oldclock = os.clock()
- dClock = os.clock()
- total = 0
- if peripheral.getType("top") == "monitor" then
- monitor = true
- else monitor = false
- end
- for i = 1, 9 do
- total = turtle.getItemCount(i) + total
- end
- timetil = round((1024 - total)*1.47)
- if monitor then
- mon = peripheral.wrap("top")
- mon.setTextScale(1)
- mon.clear()
- end
- term.clear()
- while total < 1024 do
- turtle.select(1)
- status = "Generating cobble"
- if turtle.detect() then
- dClock = os.clock()
- ret = turtle.dig()
- if not ret then
- status = "Cannot mine block!"
- end
- else
- if (os.clock() - dClock) > 3 then
- status = "Cobble not found!"
- end
- end
- sleep(0.0001)
- total = 0
- for i = 1, 16 do
- total = turtle.getItemCount(i) + total
- end
- if monitor then
- mon.clear()
- mon.setCursorPos(1, 1)
- end
- etime = round(os.clock() - oldclock)
- if status ~= "Generating cobble" then
- else
- if oldtotal == total and oldetime ~= etime then
- if counter < 6 then
- timetil = timetil-(etime - oldetime)
- counter = counter+1
- else
- counter = 0
- timetil = round((1024 - total)*1.47)
- end
- elseif round((1024 - total)*1.47) < timetil then
- counter = 0
- timetil = round((1024 - total)*1.47)
- end
- end
- per = round((total/1024)*23)
- bar = string.rep("=", per)
- if monitor then
- mon.setCursorPos(1, 1)
- mon.write("Status: " .. status)
- mon.setCursorPos(1, 2)
- mon.write("Total cobble: " .. total)
- mon.setCursorPos(1, 3)
- mon.write("Time elapsed: " .. etime .. " seconds")
- mon.setCursorPos(1, 4)
- mon.write("Time to finish: " .. timetil .. " seconds")
- mon.setCursorPos(1, 5)
- mon.write("[" .. bar)
- mon.setCursorPos(26, 5)
- mon.write("]")
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("Status: " .. status)
- print("Total cobble: " .. total)
- print("Time elapsed: " .. etime .. " seconds")
- print("Time to finish: " .. timetil .. " seconds")
- print("[" .. bar)
- term.setCursorPos(26, 5)
- print("]")
- oldtotal = total
- oldetime = etime
- end
- if monitor then
- mon.setCursorPos(1, 1)
- mon.clearLine()
- mon.write("Status: Full!")
- mon.setCursorPos(1, 5)
- mon.clearLine()
- mon.write("Please empty and reboot!")
- end
- term.setCursorPos(1, 1)
- term.clearLine()
- write("Status: Full!")
- term.setCursorPos(1, 5)
- term.clearLine()
- if not chest then
- write("Press [CTRL] to empty and reboot!")
- while true do
- event, key = os.pullEvent("key")
- if key == 29 then break end
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- turtle.turnLeft()
- turtle.turnLeft()
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement