Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1, 1)
- print("minimum fuel-level: ")
- print("explore (y/n): ")
- print("stationary (y/n): ")
- term.setCursorPos(20, 1)
- minFuelLevel = read()
- term.setCursorPos(15, 2)
- explore = read()
- term.setCursorPos(19, 3)
- stationary = read()
- if minFuelLevel == "full"then
- minFuelLevel = turtle.getFuelLimit()
- else
- minFuelLevel = tonumber(minFuelLevel)
- end
- if explore == "y" then
- explore = true
- else
- explore = false
- end
- if stationary == "y" then
- stationary = true
- else
- stationary = false
- end
- ---------------------------------------------------------------------------------------
- function findBucket()
- for i=1,16 do
- local itemD = turtle.getItemDetail(i)
- if not (itemD==nil) then
- if itemD.name=="minecraft:bucket" then
- turtle.select(i)
- return true
- end
- end
- end
- return false
- end
- ---------------------------------------------------------------------------------------
- function forward()
- for i=1,10 do
- if turtle.forward() then
- return true
- end
- turtle.attack()
- end
- return false
- end
- function down()
- for i=1,10 do
- if turtle.down() then
- return true
- end
- end
- return false
- end
- function up()
- while not turtle.up() do
- turtle.digUp()
- turtle.attackUp()
- end
- end
- function backTrack()
- turtle.turnLeft()
- turtle.turnLeft()
- for i, dir in ipairs(moved) do
- if dir=="f" then
- forward()
- else
- up()
- end
- end
- end
- -----------------------------------------------------------------------------------------
- paintutils.drawFilledBox(1, 1, 39, 19, colors.red)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.setCursorPos(12, 7)
- term.write("nu bucket")
- while not findBucket() do
- sleep(0.5)
- end
- paintutils.drawFilledBox(1, 1, 39, 19, colors.orange)
- term.setBackgroundColor(colors.orange)
- term.setTextColor(colors.white)
- term.setCursorPos(12, 7)
- term.write("filling up")
- moved = {}
- if explore then
- hasBlock, blockData = turtle.inspectDown()
- while ((not (blockData.name == "minecraft:lava")) or blockData.name==nil) do
- if (not hasBlock) then
- if not down() then
- backTrack()
- paintutils.drawFilledBox(1, 1, 39, 19, colors.orange)
- term.setBackgroundColor(colors.orange)
- term.setTextColor(colors.white)
- term.setCursorPos(2, 7)
- term.write("obstacle Found while exploring")
- os.pullEvent("key")
- os.reboot()
- else
- table.insert(moved, 1, "d")
- end
- else
- if not forward() then
- backTrack()
- paintutils.drawFilledBox(1, 1, 39, 19, colors.orange)
- term.setBackgroundColor(colors.orange)
- term.setTextColor(colors.white)
- term.setCursorPos(2, 7)
- term.write("obstacle Found while exploring")
- os.pullEvent("key")
- os.reboot()
- else
- table.insert(moved, 1, "f")
- end
- end
- hasBlock, blockData = turtle.inspectDown()
- end
- end
- if not findBucket() then
- paintutils.drawFilledBox(1, 1, 39, 19, colors.red)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.setCursorPos(12, 7)
- term.write("no bucket")
- backTrack()
- os.pullEvent("key")
- os.reboot()
- end
- while turtle.getFuelLevel() <= minFuelLevel do
- turtle.placeDown()
- turtle.refuel()
- if not stationary then
- if forward() then
- table.insert(moved, 1, "f")
- else
- backTrack()
- paintutils.drawFilledBox(1, 1, 39, 19, colors.orange)
- term.setBackgroundColor(colors.orange)
- term.setTextColor(colors.white)
- term.setCursorPos(2, 7)
- term.write("obstacle Found while filling")
- os.pullEvent("key")
- os.reboot()
- end
- end
- end
- backTrack()
- paintutils.drawFilledBox(1, 1, 39, 19, colors.lime)
- term.setBackgroundColor(colors.lime)
- term.setTextColor(colors.white)
- term.setCursorPos(12, 7)
- term.write("finished")
- os.pullEvent("key")
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement