Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x,y = 0,0
- local direction = "north"
- local dirInstruct = ...
- function testForAvailableFuel()
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- return true
- end
- end
- end
- function fuel()
- if not turtle.getFuelLevel() <= math.floor(turtle.getFuelLimit()/2) or not testForAvailableFuel() then return end
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- local halfStack = math.floor(turtle.getItemCount(i)/2)
- turtle.refuel(halfStack)
- end
- end
- end
- function forward(dirToGo)
- if dirToGo == "north" then
- y = y + 1
- if direction == "north" then
- turtle.forward()
- elseif direction == "south" then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- elseif direction == "west" then
- turtle.turnRight()
- turtle.forward()
- elseif direction == "east" then
- turtle.turnLeft()
- turtle.forward()
- end
- direction = "north"
- elseif dirToGo == "east" then
- x = x + 1
- if direction == "north" then
- turtle.turnRight()
- turtle.forward()
- elseif direction == "west" then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- elseif direction == "east" then
- turtle.forward()
- elseif direction == "south" then
- turtle.turnLeft()
- turtle.forward()
- end
- direction = "east"
- elseif dirToGo == "south" then
- y = y - 1
- if direction == "south" then
- turtle.forward()
- elseif direction == "north" then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- elseif direction == "east" then
- turtle.turnRight()
- turtle.forward()
- elseif direction == "west" then
- turtle.turnLeft()
- turtle.forward()
- end
- direction = "south"
- elseif dirToGo == "west" then
- x = x - 1
- if direction == "west" then
- turtle.forward()
- elseif direction == "east" then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- elseif direction == "south" then
- turtle.turnRight()
- turtle.forward()
- elseif direction == "north" then
- turtle.turnLeft()
- turtle.forward()
- end
- direction = "west"
- end
- fuel()
- end
- forward(dirInstruct)
Advertisement
Add Comment
Please, Sign In to add comment