Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- move program by Caio "Jabulba" Jabulka 2015
- -- Turtle type: Mining Turtle
- -- Purpose: Turtle moves the specified amount of times forward.
- -- Licensed MIT
- local enderChestId = "EnderStorage:enderChest"
- local inventoryEmptiedCount = 0
- local args = {...}
- args[1] = tonumber(args[1]) or 1
- assert(type(args[1]) == "number", "Expected at most one argument as number.")
- if not(args[2] == "l" or args[2] == "r" or args[2] == "left" or args[2] == "right") then
- args[1] = 0
- error("Provided direction " .. args[2] .. " is invalid. Try 'l' or 'r'")
- end
- local function checkFuel()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel < 5 then
- print("CRITICAL: FUEL LEVEL CRITICAL.")
- print("EMERGENCY REFUELING INITIATED.")
- for slot = 1, 16, 1 do
- if turtle.refuel() then
- break
- end
- end
- elseif fuelLevel < 25 then
- print("CRITICAL: FUEL LEVEL EXTREMELY LOW.")
- elseif fuelLevel < 500 then
- print("WARNING: FUEL LEVEL LOW.")
- end
- end
- local function turtleTurn(direction, attempts)
- direction = direction or "left"
- attempts = attempts or 1
- checkFuel()
- if attempts > 30 then
- return false
- end
- if direction == "l" or direction == "left" then
- if not turtle.turnLeft() then
- turtleTurn("f", attempts)
- end
- elseif direction == "r" or direction == "right" then
- if not turtle.turnRight() then
- turtle.attackDown()
- turtleTurn("d", attempts)
- end
- end
- return true
- end
- for runs = 1, args[1], 1 do
- turtleTurn(args[2])
- end
Advertisement
Add Comment
Please, Sign In to add comment