Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Move forward in a line for amnt blocks
- --- Return false if the turtle gets stuck midway
- function lineMotion(amnt)
- for x = 1, amnt do
- local b = turtle.forward()
- if not b then
- return b;
- end
- end
- end
- --- Performs func and moves one block forward
- --- repeats x times
- --- Returns true if successfully moves and performs func
- --- for the entire length, false otherwise
- function lineMotionDoWhile(x, func)
- for xI = 1, x do
- local b = func()
- if not b then
- return b;
- end
- b = turtle.forward()
- if not b then
- return b;
- end
- end
- return true
- end --lineMotionDoWhile
- --- Moves in a rect shape and performs func
- --- Always performs the func first before moving
- --- Returns false if movement is blocked, true otherwise
- function rectMotionDoWhile(x, y, func)
- local turn = turtle.turnLeft
- for xI = 1, x do
- --- Decide to turn left or right
- if xI % 2 == 0 then
- turn = turtle.turnLeft
- else
- turn = turtle.turnRight
- end
- --- Move in a line
- local b = lineMotionDoWhile(y, func)
- if not b then
- return b
- end
- --- Move to next row
- turn()
- turtle.forward()
- turn()
- end --- for xI = 1, x do
- end --- rectMotionDoWhile
- function hasEnoughFuel(x, y, z)
- x = math.max(x, 1)
- y = math.max(y, 1)
- z = math.max(z, 1)
- local fuel = turtle.getFuelLevel()
- return fuel >= x * y * z
- end --- hasEnoughFuel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement