Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- A bot to drain as much as lava as possible from the nether world
- if fs.exists("extraFuncsApi") then
- os.loadAPI("extraFuncsApi")
- else
- shell.run("pastebin", "get", "5MwHEZxB", "extraFuncsApi")
- os.loadAPI("extraFuncsApi")
- end
- if fs.exists("serverApi") then
- os.loadAPI("serverApi")
- else
- shell.run("pastebin", "get", "dazENzF5", "serverApi")
- os.loadAPI("serverApi")
- end
- if fs.exists("facilityApi") then
- os.loadAPI("facilityApi")
- else
- shell.run("pastebin", "get", "Eyrmtw0m", "facilityApi")
- os.loadAPI("facilityApi")
- end
- local lava_turtle = extraFuncsApi.extraFuncs:new(vector.new(0, 0, 0), "N", true)
- local bucket = peripheral.wrap("left")
- local lava_collector_data = {
- home = vector.new(0, 0, 0),
- lava_counter = 0
- }
- function init()
- print("Ender chest slot 1, pickaxe slot 2")
- if not fs.exists("startup") then
- print("Making startup file")
- local h = fs.open("startup", "w")
- h.writeLine("sleep(1)")
- h.writeLine("shell.run('" .. shell.getRunningProgram() .. "')")
- h.close()
- end
- if(read_lava_collector_data() == false) then
- save_lava_collector_data()
- end
- lava_turtle:read_pos()
- collectLava()
- end
- function collectLava()
- while true do
- if checkDown() == "lava" then
- repeat
- getLava("down")
- lava_turtle:down()
- print("whent down")
- lava_turtle:save_pos()
- until checkDown() == "something"
- goToZ(lava_collector_data.home)
- end
- -- Get lava or Turn
- if checkLava() == "lava" then
- getLava("")
- lava_turtle:forward()
- lava_turtle:save_pos()
- elseif checkLava() == "something" then
- if lava_turtle.turtle_pos.x % 2 == 0 then
- lava_turtle:right()
- lava_turtle:forward()
- lava_turtle:right()
- lava_turtle:save_pos()
- else
- lava_turtle:left()
- lava_turtle:forward()
- lava_turtle:left()
- lava_turtle:save_pos()
- end
- else
- lava_turtle:forward()
- lava_turtle:save_pos()
- end
- end
- end
- function getLava(direction)
- sendLava()
- if direction == "down" then
- if checkDown() == "lava" then
- print("Saw lava")
- while bucket.suckDown() == false do
- bucket = peripheral.wrap("left")
- bucket.suckDown()
- end
- print("Should've sucked")
- end
- elseif direction == "up" then
- if checkUp() == "lava" then
- print("Saw lava")
- while bucket.suckUp() == false do
- bucket = peripheral.wrap("left")
- bucket.suckUp()
- end
- print("Should've sucked")
- end
- else
- if checkLava() == "lava" then
- print("Saw lava")
- while bucket.suck() == false do
- bucket = peripheral.wrap("left")
- bucket.suck()
- end
- print("Should've sucked")
- end
- end
- sleep(0.2)
- if bucket.getFluid() ~= nil then
- print(tonumber(bucket.getFluid().amount))
- end
- end
- function sendLava()
- if bucket.getFluid() ~= nil and tonumber(bucket.getFluid().amount) == 8000 then
- lava_turtle:left()
- lava_turtle:left()
- turtle.select(1)
- while turtle.placeUp() == false do
- turtle.digUp()
- turtle.suckUp()
- turtle.placeUp()
- end
- while tonumber(peripheral.wrap("left").getFluid().amount) ~= 0 or peripheral.wrap("left").getFluid() ~= nil do
- bucket = peripheral.wrap("left")
- bucket.emptyUp()
- print(tonumber(bucket.getFluid().amount))
- sleep(0.1)
- end
- turtle.select(2)
- turtle.equipLeft()
- turtle.select(1)
- turtle.digUp()
- turtle.select(2)
- turtle.equipLeft()
- bucket = peripheral.wrap("left")
- lava_turtle:right()
- lava_turtle:right()
- lava_collector_data.lava_counter = lava_collector_data.lava_counter + 1
- save_lava_collector_data()
- end
- end
- function save_lava_collector_data()
- local h = fs.open("lava_collector_data", "w")
- h.write(tonumber(lava_collector_data.lava_counter))
- h.close()
- end
- function read_lava_collector_data()
- if fs.exists("lava_collector_data") then
- local h = fs.open("lava_collector_data", "r")
- lava_collector_data.lava_counter = tonumber(readLine())
- h.close()
- return true
- else
- return false
- end
- end
- function checkLava()
- local success, t = turtle.inspect()
- if success then
- if string.find(t.name, "lava") ~= nil then
- return "lava"
- else
- return "something"
- end
- else
- return "nothing"
- end
- end
- function checkDown()
- local success, t = turtle.inspectDown()
- if success then
- if string.find(t.name, "lava") ~= nil then
- return "lava"
- else
- return "something"
- end
- else
- return "nothing"
- end
- end
- function checkUp()
- local success, t = turtle.inspectUp()
- if success then
- if string.find(t.name, "lava") ~= nil then
- return "lava"
- else
- return "something"
- end
- else
- return "nothing"
- end
- end
- function goToZ(place)
- if lava_turtle.turtle_pos.z ~= place.z then
- if lava_turtle.turtle_pos.z > place.z then
- while lava_turtle.turtle_pos.z ~= place.z do
- lava_turtle:down()
- end
- elseif lava_turtle.turtle_pos.z < place.z then
- while lava_turtle.turtle_pos.z ~= place.z do
- lava_turtle:up()
- end
- end
- end
- end
- init()
Advertisement
Add Comment
Please, Sign In to add comment