Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local controlChest = peripheral.wrap("front")
- -- variable for mining lenght
- local time = 0
- local number = true
- -- The following function rounds a number to the given number of decimal places.
- function round(num, idp)
- local mult = 10^(idp or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- -- how long to mine
- print("How long time would you like to mine in minutes:")
- time = assert(tonumber(read()),"input is not a number")
- print("To abort the operation")
- print("hold ENTER")
- --if number == false then
- -- return
- --else
- -- calculate the time to seconds
- time = time * 60
- --end
- -- put an item in the chest
- -- and sleep for selected time
- turtle.select(1)
- turtle.drop()
- local on = true
- local interval = 0.5
- local timer = os.startTimer(0)
- while time > 0 do
- --sleep(1)
- -- if we want the miner to quit early then press enter
- -- this part of the code is from billysback
- local event, p1, p2, p3 = os.pullEvent()
- if event == "timer" then
- --Update program
- sleep(0.5)
- -- print the time left, but only the whole minutes
- -- and only once a minute
- -- if time is evenly divided by 60 (that is woth no riminder)
- if (time % 60) == 0 then
- print("Time left: " ..math.floor(time/60).. " minutes")
- end
- --print("Time left: " ..time.. " ticks")
- time = time - 1
- timer = os.startTimer(interval)
- else
- local key = p1
- if key == 28 then --enter
- on = false
- break
- end
- end
- --[[
- sleep(1)
- -- print the time left, but only the whole minutes
- -- and only once a minute
- -- if time is evenly divided by 60 (that is woth no riminder)
- if (time % 60) == 0 then
- print("Time left: " ..math.floor(time/60).. " minutes")
- end
- --print("Time left: " ..time.. " ticks")
- time = time - 1
- ]]
- end
- -- put it back into the turtle to end the mining session
- controlChest.pushItem("south",1,64,1)
- -- print that it's done
- print("DONE!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement