Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local done = false
- local sleepp = 5
- local Debug = 2 --[[ 1 - on, 2 - off ]]
- function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function Bed()
- local bed1 = sleepp
- local bed2 = bed1 * 0.25
- local bed3 = bed1 * 0.50
- local bed4 = bed1 * 0.75
- print("Sleep ",bed1,"s more...")
- sleep(bed2)
- print("Sleep ",bed4,"s more...")
- sleep(bed2)
- print("Sleep ",bed3,"s more...")
- sleep(bed2)
- print("Sleep ",bed2,"s more...")
- sleep(bed2)
- Clear()
- end
- function Waiting()
- Clear()
- print("Waiting for job")
- local event, p1 = os.pullEvent("turtle_inventory")
- os.reboot()
- end
- function sDown()
- if Debug == 1 then
- print("sDown")
- end
- for d = 1,12 do
- turtle.select(d)
- turtle.dropDown()
- end
- turtle.select(1)
- for i = 1,12 do
- turtle.suckDown()
- end
- end
- function FileCheck()
- if Debug == 1 then
- print("FileCheck")
- end
- local file = fs.open("IterationFile", "r")
- Iteration = file.readAll()
- file.close()
- end
- function CheckItems()
- if Debug == 1 then
- print("CheckItems")
- end
- turtle.select(1)
- if (turtle.getItemCount(1) == 0) then
- FileCheck()
- if tonumber(Iteration)>0 then
- Iteration2 = Iteration - 1
- IterFile = io.open("IterationFile", "w")
- IterFile : write(Iteration2)
- IterFile : close()
- else
- IterFile = io.open("IterationFile", "w")
- IterFile : write(2)
- IterFile : close()
- Waiting()
- end
- else
- CompareTo()
- end
- end
- function CompareTo()
- if Debug == 1 then
- print("CompareTo")
- end
- for i = 1,12 do
- turtle.select(i)
- done = turtle.compareTo(16) or turtle.compareTo(15) or turtle.compareTo(14) or turtle.compareTo(13)
- if done then
- turtle.drop()
- elseif turtle.compareTo(15) then
- else
- turtle.dropDown()
- end
- end
- end
- function NewFile()
- if Debug == 1 then
- print("NewFile")
- end
- if not fs.exists("IterationFile") then
- IterFile = io.open("IterationFile", "w")
- IterFile : write(2)
- IterFile : close()
- end
- end
- while true do
- NewFile()
- turtle.select(1)
- sDown()
- CheckItems()
- Bed()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement