Advertisement
mDiyo

moveturtle

Dec 1st, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. local tArgs = {...}
  2. fPos = tArgs[1]
  3. yPos = tArgs[2]
  4. rPos = tArgs[3]
  5. if fPos == nil or yPos == nil or rPos == nil then
  6.   print("Usage: moveturtle <forward> <up> <right>")
  7.   return -1
  8. end
  9. fPos = tonumber(fPos)
  10. yPos = tonumber(yPos)
  11. rPos = tonumber(rPos)
  12.  
  13. x = 0
  14. y = 0
  15. z = 0
  16.  
  17. if yPos < 0 then
  18.   yPos = -yPos
  19.   for y = 0, yPos-1, 1 do
  20.     turtle.down()
  21.   end
  22. elseif yPos > 0 then
  23.   for y = 0, yPos-1, 1 do
  24.     turtle.up()
  25.   end
  26. end
  27.  
  28. if fPos < 0 then
  29.   fPos = -fPos
  30.   turtle.turnRight()
  31.   turtle.turnRight()
  32. end
  33.  
  34. for f = 0, fPos - 1, 1 do
  35.   turtle.forward()
  36. end
  37.  
  38. if rPos < 0 then
  39.   rPos = -rPos
  40.   turtle.turnLeft()
  41. elseif rPos > 0 then
  42.   turtle.turnRight()
  43. end
  44.  
  45. for r = 0, rPos - 1, 1 do
  46.   turtle.forward()
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement