Advertisement
Guest User

Untitled

a guest
May 25th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. --[[
  2. Move functions
  3. version 0.2
  4. --]]
  5.  
  6. function shiftLeft(len)
  7. turtle.turnLeft()
  8. for i = 1,len do
  9. turtle.forward()dbs l
  10. end
  11. turtle.turnRight()
  12. end
  13.  
  14. function shiftRight(len)
  15. turtle.turnRight()
  16. for i = 1,len do
  17. turtle.forward()
  18. end
  19. turtle.turnLeft()
  20. end
  21.  
  22.  
  23. -- main
  24.  
  25. local args = { ... }
  26.  
  27. if #args < 1 then
  28. return
  29. end
  30. local command = args[1]
  31.  
  32. local len = 1
  33. if #args >= 2 then
  34. len = tonumber(args[2])
  35. end
  36.  
  37. fnMove = nil
  38. if command == "u" then
  39. fnMove = turtle.up
  40. elseif command == "d" then
  41. fnMove = turtle.down
  42. elseif command == "b" then
  43. fnMove = turtle.back
  44. elseif command == "f" then
  45. fnMove = turtle.forward
  46. elseif command == "r" then
  47. fnMove = turtle.turnRight
  48. elseif command == "l" then
  49. fnMove = turtle.turnLeft
  50. elseif command == "sl" then
  51. -- shift left
  52. shiftLeft(len)
  53. return
  54. elseif command == "sr" then
  55. -- shift right
  56. shiftRight(len)
  57. return
  58. end
  59.  
  60. if fnMove ~= nil then
  61. for i = 1,len do
  62. while not fnMove() do
  63. end
  64. end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement