Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local times_swapped
- local counter = 120
- function run()
- while(true) do
- print("Getting buckets")
- turtle.turnRight()
- for i=1,16 do
- turtle.select(i)
- turtle.suck(1)
- end
- turtle.turnRight()
- print("Filling buckets")
- for i=1,16 do
- turtle.select(i)
- turtle.place()
- end
- turtle.turnRight()
- print("Returning buckets")
- for i=1,16 do
- turtle.select(i)
- item_data = turtle.getItemDetail(i)
- if(item_data ~= nil) then
- if(string.find(item_data.name, "lava_bucket")) then
- turtle.drop(1)
- times_swapped = times_swapped + 1
- end
- end
- local h = fs.open("autofurnace/times_lavaswapped", "w")
- h.writeLine(times_swapped)
- h.close()
- end
- turtle.turnRight()
- repeat
- print("Swapped empty buckets with full buckets " .. times_swapped .. " times.")
- print("")
- print("Waiting " .. counter .. " seconds.")
- sleep(1)
- term.clear()
- counter = counter - 1
- until counter == 0
- counter = 120
- end
- end
- function start()
- if fs.exists("autofurnace") then
- print("Furnace folder exists, probably a crash")
- crashReport()
- checkDirection()
- crashed_checkInv()
- term.clear()
- run()
- else
- print("making folder")
- fs.makeDir("autofurnace")
- local h = fs.open("autofurnace/times_lavaswapped", "w")
- h.writeLine(0)
- h.close()
- local h = fs.open("autofurnace/times_crashed", "w")
- h.writeLine(0)
- h.close()
- checkDirection()
- term.clear()
- times_swapped = 0
- run()
- end
- end
- function crashReport()
- print("Making crash report")
- local times_crashed
- local h = fs.open("autofurnace/times_crashed", "r")
- times_crashed = tonumber(h.readLine())
- h.close()
- times_crashed = times_crashed + 1
- local h = fs.open("autofurnace/times_crashed", "w")
- h.writeLine(times_crashed)
- h.close()
- local h = fs.open("autofurnace/times_lavaswapped", "r")
- times_swapped = tonumber(h.readLine())
- h.close()
- end
- function checkDirection()
- print("Getting right direction")
- if turtle.forward() == false then
- repeat
- turtle.turnLeft()
- until turtle.forward() == true
- end
- turtle.back()
- end
- function crashed_checkInv()
- print("Empty inventory after crash")
- local item_data
- for i=1,16 do
- turtle.select(i)
- item_data = turtle.getItemDetail(i)
- if(item_data ~= nil) then
- if(string.find(item_data.name, "bucket")) then
- if(item_data.count > 1) then
- turtle.turnRight()
- turtle.drop(item_data.count - 1)
- turtle.turnLeft()
- end
- elseif(string.find(item_data.name, "lava_bucket")) then
- turtle.turnLeft()
- turtle.drop()
- turtle.turnRight()
- else
- turtle.dropDown(item_data.count)
- end
- end
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment