Advertisement
HarvDad

r

Mar 14th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. -- r
  2. -- Turns and/or move the turtle to the right
  3. -- Written by HarvDad, March 2014
  4.  
  5. args = {...}
  6. nArgs = #args
  7.  
  8. x = 0
  9. y = 0
  10. z = 0
  11. face = 0
  12. minimumFuel = 100
  13. abort = false
  14. local currentFuelLevel = turtle.getFuelLevel()
  15. distance = nil;
  16.  
  17. if (nArgs == 1 and args[1]== "help") then
  18. print("Turns and/or moves the turtle to the right")
  19. print("Usage: r [distance]")
  20. return
  21. end
  22.  
  23. if nArgs == 1 then
  24. distance = tonumber(args[1])
  25. if distance == nil then
  26. print(args[1], " is not a valid distance")
  27. return
  28. end
  29. end
  30.  
  31. -- MAIN PROGRAM
  32.  
  33. turtle.turnRight()
  34.  
  35. if distance ~= nil then
  36. turtle.select(1)
  37.  
  38. if currentFuelLevel ~= "unlimited" then
  39. if currentFuelLevel < minimumFuel then
  40. if not turtle.refuel() then
  41. print("No fuel")
  42. return
  43. end
  44. end
  45. end
  46.  
  47. for i=1,distance do
  48. turtle.forward()
  49. end
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement