Advertisement
Guest User

move

a guest
Nov 26th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1.  
  2. local tArgs = { ... }
  3. if #tArgs ~= 2 then
  4.   print("Usage: move <u/d/l/r/f/b> <amount>")
  5.   return
  6. end
  7. local function move(x)
  8. if x == "l" then
  9. turtle.turnLeft()
  10. elseif x == "f" then
  11. turtle.forward()
  12. elseif x == "r" then
  13. turtle.turnRight()
  14. elseif x == "b" then
  15. turtle.back()
  16. elseif x == "u" then
  17. turtle.up()
  18. elseif x == "d" then
  19. turtle.down()
  20. end
  21. end
  22. local d = tArgs[1]
  23. local n = tArgs[2]
  24. local function nlr(d,n)
  25. for i = 1, n do
  26.   move(d)
  27. end
  28. end
  29. local function lr(d,n)
  30. move(d)
  31. dir="f"
  32. nlr(dir,n)
  33. end
  34. if d=="l" then
  35. lr(d,n)
  36. elseif d=="r" then
  37. lr(d,n)
  38. else
  39. nlr(d,n)
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement