Advertisement
massacring

Move

Jul 19th, 2024 (edited)
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. local MiningLib = require('MassaMiningTurtleLib')
  2.  
  3. local distance = tonumber(arg[1]) or 1
  4. local direction = arg[2]
  5. local force = false
  6.  
  7. if (arg[3] and string.lower(arg[3])) == "force" then force = true end
  8.  
  9. local move = (force) and MiningLib.digAndMoveForward or turtle.forward;
  10. if direction == "back" or direction == "b" then
  11.     if force then print("Cannot forcibly move backwards.") end
  12.     move = turtle.back;
  13. elseif direction == "up" or direction == "u" then
  14.     move = (force) and MiningLib.digAndMoveUp or turtle.up;
  15. elseif direction == "down" or direction == "d" then
  16.     move = (force) and MiningLib.digAndMoveDown or turtle.down;
  17. end
  18.  
  19. local fuel = turtle.getFuelLevel()
  20. local requiredFuel = distance
  21. if fuel < requiredFuel then
  22.     error(string.format("[%d/%d] - Turtle requires %d more fuel.", fuel, requiredFuel, (requiredFuel-fuel)), 0)
  23. end
  24.  
  25. for _ = 1, distance, 1 do
  26.     move()
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement