Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function printFuel()
- fuel=turtle.getFuelLevel()
- fuelbar=math.floor(fuel/100)
- if fuelbar>20 then
- fuelbar=20
- end
- term.clear()
- term.setCursorPos(1,1)
- print("------------------------")
- term.write("--")
- for i=1,fuelbar do
- term.write("#")
- end
- for j=fuelbar,19 do
- term.write("=")
- end
- print("--")
- print("------------------------")
- print(fuel.." Steps left")
- end
- function checkFuel()
- if turtle.getFuelLevel() < 100 then
- turtle.select(16)
- turtle.refuel()
- turtle.select(1)
- end
- printFuel()
- end
- function df()
- if turtle.detect() then
- turtle.dig()
- end
- end
- function f()
- while turtle.detect() do
- df()
- sleep(0.5)
- end
- turtle.forward()
- checkFuel()
- end
- function du()
- if turtle.detectUp() then
- turtle.digUp()
- end
- end
- function u()
- while turtle.detectUp() do
- du()
- sleep(0.5)
- end
- turtle.up()
- checkFuel()
- end
- function r()
- turtle.turnRight()
- end
- function l()
- turtle.turnLeft()
- end
- function dd()
- if turtle.detectDown() then
- turtle.digDown()
- end
- end
- function d()
- dd()
- turtle.down()
- checkFuel()
- end
- function main()
- checkFuel()
- term.write("Enter WxH: ")
- WxH=read()
- if string.find(WxH,"x") then
- W=string.sub(WxH,1,string.find(WxH,"x")-1)
- H=string.sub(WxH,string.find(WxH,"x")+1)
- if tonumber(W) and tonumber(H) then
- for i=1,W do
- for j=1,H do
- f()
- end
- if i%2==1 then
- r()
- f()
- r()
- else
- l()
- f()
- l()
- end
- end
- else
- print("ERR: Not a Number in W or H")
- end
- else
- print("ERR: Wrong Format")
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement