Advertisement
Guest User

test.lua

a guest
Aug 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. curPos = {
  2.   x = 0,
  3.   y = 0,
  4.   z = 0,
  5.   rot = 0
  6. }
  7.  
  8. function ReturnHome()
  9.   if curPos.x > 0 then
  10.     MoveDir(curPos.x, -90)
  11.   elseif curPos.x < 0 then
  12.     MoveDir(-curPos.x, 90)
  13.   end
  14.  
  15.   if curPos.z > 0 then
  16.     MoveDir(curPos.z, 180)
  17.   elseif curPos.z < 0 then
  18.     MoveDir(-curPos.z, 0)
  19.   end
  20.  
  21.   if curPos.y > 0 then
  22.     while curPos.y > 0 do
  23.       MoveDown(curPos.y)
  24.     end
  25.   elseif curPos.y < 0 then
  26.     MoveUp(-curPos.y)
  27.   end
  28. end
  29.  
  30. function MoveDir(num, dir)
  31.  
  32. end
  33.  
  34. function Rotate(dir)
  35.  
  36. end
  37.  
  38. function MoveUp(num)
  39.  
  40. end
  41.  
  42. function MoveDown(num)
  43.  
  44. end
  45.  
  46. function MoveForwards(num)
  47.   counter = 0
  48.   while (counter < num) do
  49.     if (curPos.rot == 0) then
  50.       if turtle.forward() then
  51.         curPos.z = curPos.z + 1
  52.       end
  53.     elseif (curPos.rot == 90) then
  54.       if turtle.forward() then
  55.         curPos.x = curPos.x + 1
  56.       end
  57.     elseif (curPos.rot == -90) then
  58.       if turtle.forward() then
  59.         curPos.x = curPos.x - 1
  60.       end
  61.     elseif (curPos.rot == 180) then
  62.       if turtle.forward() then
  63.         curPos.z = curPos.z - 1
  64.       end
  65.     end
  66.     counter = counter + 1
  67.   end
  68. end
  69.  
  70. MoveForwards(5)
  71. print(curPos.x .. ", " .. curPos.y .. ", " .. curPos.z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement