Advertisement
Descaii

robo2

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