Advertisement
Descaii

asdasd

Jan 26th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1. PosOffset = {x=0,y=0,z=0}
  2. Forward = {x=1,y=0,z=0}
  3. function ShiftOffsetForward()
  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.     if direction=="right" then
  10.         if Forward.x==1 then
  11.             Forward.x=0
  12.             Forward.z=1
  13.         elseif Forward.z==1 then
  14.             Forward.x=-1
  15.             Forward.z=0
  16.         elseif Forward.x==-1 then
  17.             Forward.x=0
  18.             Forward.z=-1
  19.         elseif Forward.z==-1 then
  20.             Forward.z=0
  21.             Forward.x=1
  22.         end
  23.     end
  24.     if direction=="left" then
  25.         if Forward.x==1 then
  26.             Forward.x=0
  27.             Forward.z=-1
  28.         elseif Forward.z==-1 then
  29.             Forward.x=-1
  30.             Forward.z=0
  31.         elseif Forward.x==-1 then
  32.             Forward.x=0
  33.             Forward.z=1
  34.         elseif Forward.z==1 then
  35.             Forward.z=0
  36.             Forward.x=1
  37.         end
  38.     end
  39. end
  40. function forward(shift)
  41.     if shift and turtle.forward() then
  42.         ShiftOffsetForward()
  43.     end
  44. end
  45. function left(move)
  46.     shift("left")
  47.     turtle.turnLeft()
  48.     if move then forward(true) end
  49. end
  50. function right(move)
  51.     shift("right")
  52.     turtle.turnRight()
  53.     if move then forward(true) end
  54. end
  55. left(true)
  56. forward(true)
  57. forward(true)
  58. while true do
  59.     right(true)
  60.     print("Pos:"..PosOffset.x..","..PosOffset.y..","..PosOffset.z.." Rot:"..Forward.x..","..Forward.y..","..Forward.z)
  61.     forward(true)
  62.     print("Pos:"..PosOffset.x..","..PosOffset.y..","..PosOffset.z.." Rot:"..Forward.x..","..Forward.y..","..Forward.z)
  63.     forward(true)
  64.     print("Pos:"..PosOffset.x..","..PosOffset.y..","..PosOffset.z.." Rot:"..Forward.x..","..Forward.y..","..Forward.z)
  65.     right(true)
  66.     print("Pos:"..PosOffset.x..","..PosOffset.y..","..PosOffset.z.." Rot:"..Forward.x..","..Forward.y..","..Forward.z)
  67.     forward(true)
  68.     print("Pos:"..PosOffset.x..","..PosOffset.y..","..PosOffset.z.." Rot:"..Forward.x..","..Forward.y..","..Forward.z)
  69.     forward(true)
  70.     print("Pos:"..PosOffset.x..","..PosOffset.y..","..PosOffset.z.." Rot:"..Forward.x..","..Forward.y..","..Forward.z)
  71.     right(true)
  72.     print("Pos:"..PosOffset.x..","..PosOffset.y..","..PosOffset.z.." Rot:"..Forward.x..","..Forward.y..","..Forward.z)
  73.     forward(true)
  74.     print("Pos:"..PosOffset.x..","..PosOffset.y..","..PosOffset.z.." Rot:"..Forward.x..","..Forward.y..","..Forward.z)
  75.     forward(true)
  76.     print("Pos:"..PosOffset.x..","..PosOffset.y..","..PosOffset.z.." Rot:"..Forward.x..","..Forward.y..","..Forward.z)
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement