Advertisement
Descaii

TestRun

Feb 1st, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. PosOffset = {x=0,y=0,z=0}
  2. Forward = {x=1,y=0,z=0}
  3. function Move(direction)
  4.     PosOffset.x=PosOffset.x+Forward.x
  5.     PosOffset.y=PosOffset.y+Forward.y
  6.     PosOffset.z=PosOffset.z+Forward.z
  7. end
  8. function shift(direction)
  9.     local x,z = Forward.x,Forward.z
  10.     if direction=="right" then
  11.         Forward.x = (z == 1 and -1) or (z == -1 and 1) or (x ~= 0 and 0)
  12.         Forward.z = (x == 1 and 1) or (x == -1 and -1) or (z ~= 0 and 0)
  13.     end
  14.     if direction=="left" then
  15.         Forward.z = (x == 1 and -1) or (x == -1 and 1) or (z ~= 0 and 0)
  16.         Forward.x = (z == 1 and 1) or (z == -1 and -1) or (x ~= 0 and 0)
  17.     end
  18. end
  19. function GetDirection()
  20.     if Forward.x==1 then
  21.         return "forward"
  22.     elseif Forward.x==-1 then
  23.         return "backwards"
  24.     elseif Forward.z==1 then
  25.         return "right"
  26.     elseif Forward.z==-1 then
  27.         return "left"
  28.     end
  29. end
  30. function IsFull()
  31.     local f = true
  32.     for i = 1,16 do
  33.         if turtle.getItemCount(i) == 0 then
  34.             f=false
  35.         end
  36.     end
  37.     return f
  38. end
  39. function Return()
  40. end
  41. function SetDirection(dir)
  42.     local DIR = GetDirection()
  43.     if DIR~=dir:lower() then
  44.         local l,r = 0,0
  45.         if DIR == "left" then
  46.             l,r = ((dir=="backwards"and 1)or 0),((dir=="forward"and 1)or(dir=="right"and 2)or 0)
  47.         elseif DIR == "right" then
  48.             l,r = ((dir=="forward"and 1)or 0),((dir=="backwards"and 1)or(dir=="left"and 2)or 0)
  49.         elseif DIR == "backwards" then
  50.             l,r = ((dir=="right"and 1)or 0),((dir=="left"and 1)or(dir=="forward"and 2)or 0)
  51.         elseif DIR == "forward" then
  52.             l,r = ((dir=="left"and 1)or 0),((dir=="right"and 1)or(dir=="backwards"and 2)or 0)
  53.         end
  54.         for i = 1,r do shift("right") turtle.turnRight() end
  55.         for i = 1,l do shift("left") turtle.turnLeft() end
  56.     end
  57. end
  58. function Quarry(x,y,z)
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement