Advertisement
Guest User

axis

a guest
Oct 24th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.38 KB | None | 0 0
  1. local args={...}
  2. numX = tonumber(args[1])
  3. numY = tonumber(args[2])
  4. numZ = tonumber(args[3])
  5.  
  6. local x = 0
  7. local y = 0
  8. local z = 0
  9. local dXZ = "z"
  10. local dY = "y"
  11. local count = 0
  12.  
  13. local startX = -282
  14. local startY = 72
  15. local startZ = 564
  16.  
  17. function Forward()
  18.         print("forward")
  19.     turtle.forward()
  20.         if dXZ == "z" then z = z + 1
  21.         elseif dXZ == "-z" then z = z - 1
  22.         elseif dXZ == "x" then x = x + 1
  23.         elseif dXZ == "-x" then x = x - 1
  24.         end
  25. end
  26.  
  27. function ChooseTurn(z)
  28.         if dXZ == "x" and z > 0 then
  29.                 print("left")
  30.         turtle.turnLeft()
  31.                 dXZ = "z"
  32.         elseif dXZ == "x" and z < 0 then
  33.                 print("right")
  34.         turtle.turnRight()
  35.                 dXZ = "-z"
  36.         elseif dXZ == "-x" and z > 0 then
  37.         print("right")
  38.         turtle.turnRight()
  39.                 dXZ = "z"
  40.         elseif dXZ == "-x" and z < 0 then
  41.                 print("left")
  42.         turtle.turnLeft()
  43.                 dXZ = "-z"
  44.         end
  45. end
  46.  
  47.  
  48. function ifPosX(x)
  49.         if x > 0 then
  50.             count = x
  51.         dXZ = "x"
  52.         turtle.turnRight()
  53.     else
  54.             count = x * (-1)
  55.         dXZ = "-x"
  56.         turtle.turnLeft()
  57.         end
  58. end
  59.  
  60. function ForwardX(x)
  61.         ifPosX(x)
  62.         for i= 1,count do
  63.         Forward()
  64.     end
  65. end
  66.  
  67.  
  68. function ifPosZ(z)
  69.     if z > 0 then
  70.             count = z
  71.     else
  72.             count = z * (-1)
  73.     end
  74. end
  75.  
  76. function ForwardZ(z)
  77.         ifPosZ(z)
  78.         for i=1,count do
  79.         Forward()
  80.     end        
  81. end
  82.  
  83. function UpDown()
  84.         if dY == "y" then
  85.                 y = y + 1
  86.                 print("up")
  87.         turtle.up()
  88.         elseif dY == "-y" then
  89.                 y = y - 1
  90.                 print("down")
  91.         turtle.down()
  92.         end
  93. end  
  94.  
  95. function ifPosY(y)
  96.         if y > 0 then
  97.                 dY = "y"
  98.                 count = y
  99.         else
  100.                 dY = "-y"
  101.                 count = y * (-1)
  102.         end
  103. end
  104.  
  105. function UpDownY(y)
  106.         ifPosY(y)
  107.         for i=1,count do
  108.                 UpDown()
  109.         end
  110. end
  111.  
  112. function Print()
  113.     print("x = ".. x)
  114.         print("y = ".. y)
  115.         print("z = ".. z)
  116.         print("dXZ = "..dXZ)
  117. end
  118.  
  119.      
  120. function GetPoint(numX,numY,numZ)
  121.     ForwardX(numX)
  122.     print("dXZ = "..dXZ)
  123.     UpDownY(numY)
  124.     print("dY = "..dY)
  125.     ChooseTurn(numZ)
  126.     ForwardZ(numZ)
  127.     print("dXZ = "..dXZ)
  128. end
  129.  
  130. GetPoint(numX,numY,numZ)
  131. Print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement