Advertisement
Guest User

testStrip

a guest
Feb 20th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.59 KB | None | 0 0
  1. -- Getting Coords
  2. print("What are my Coords?: ")
  3. io.write("X: ")
  4. CurrentX = tonumber(io.read())
  5. io.write("Z: ")
  6. CurrentZ = tonumber(io.read())
  7. print("What Are my Chest's Coords?: ")
  8. io.write("X: ")
  9. ChestX = tonumber(io.read())
  10. io.write("Z: ")
  11. ChestZ = tonumber(io.read())
  12. print("Which Direction am i facing?: ")
  13. CurrentDir = tonumber(io.read())
  14.  
  15. -- getting ready to strip mine
  16. print("How many Tunnels?: ")
  17. Tunnels = tonumber(io.read())
  18. CompletedTunnels = 0
  19. print("How long is each tunnel?: ")
  20. TunnelLength = tonumber(io.read())
  21. if     CurrentDir == 0 then
  22.  DestZ = CurrentZ + TunnelLength
  23.  DestX = CurrentX
  24. elseif CurrentDir == 1 then
  25.  DestX = CurrentX - TunnelLength
  26.  DestZ = CurrentZ
  27. elseif CurrentDir == 2 then
  28.  DestZ = CurrentZ - TunnelLength
  29.  DestX = CurrentX
  30. elseif CurrentDir == 3 then
  31.  DestX = CurrentDir + TunnelLength
  32.  DestZ = CurrentZ
  33. end
  34.  
  35. function PathFind(Cx,Cz,Dx,Dz)
  36.  --Checking Directions
  37.  if Dx > Cx then
  38.   while CurrentDir ~= 3 do -- POS x
  39.    turtle.turnRight()
  40.    if CurrentDir >= 3 then
  41.     CurrentDir = 0
  42.    else
  43.     CurrentDir = CurrentDir + 1
  44.    end
  45.   end
  46.  
  47. elseif Dx < Cz then
  48.   while CurrentDir ~= 1 do -- NEG x
  49.    turtle.turnRight()
  50.    if CurrentDir >= 3 then
  51.     CurrentDir = 0
  52.    else
  53.     CurrentDir = CurrentDir + 1
  54.    end
  55.   end
  56.  end
  57.  
  58.  if CurrentDir == 1 or CurrentDir == 3 then
  59.   while Cx ~= Dx do
  60.    while turtle.detectUp() do
  61.     turtle.digUp()
  62.    end
  63.    while turtle.detect() do
  64.     turtle.dig()
  65.    end
  66.    turtle.forward()
  67.    if     CurrentDir == 1 then
  68.      Cx = Cx - 1
  69.    elseif CurrentDir == 3 then
  70.     Cx = Cx + 1
  71.    end
  72.    print("Current POS: ","X: "..Cx," Z: "..Cz)
  73.   end
  74.  else
  75.  
  76.   if Dz > Cz then
  77.    while CurrentDir ~= 0 do -- POS z
  78.     turtle.turnRight()
  79.     if Current >= 3 then
  80.      CurrentDir = 0
  81.     else
  82.     CurrentDir = CurrentDir + 1
  83.     end
  84.    end
  85.    
  86.   elseif Dz < Cz then
  87.    while CurrentDir ~= 2 do -- NEG z
  88.     turtle.turnRight()
  89.     if Current >= 3 then
  90.      CurrentDir = 0
  91.     else
  92.     CurrentDir = CurrentDir + 1
  93.     end
  94.    end
  95.   end
  96.  
  97.   while Cz ~= Dz do
  98.    while turtle.detectUp() do
  99.     turtle.digUp()
  100.    end
  101.    while turtle.detect() do
  102.     turtle.dig()
  103.    end
  104.    turtle.forward()
  105.    if     CurrentDir == 0 then
  106.      Cz = Cz + 1
  107.    elseif CurrentDir == 2 then
  108.     Cz = Cz - 1
  109.    end
  110.    print("Current POS: ","X: "..Cx," Z: "..Cz)
  111.  end
  112.  if Cx == Dx and Cz == Dz then
  113.   return true
  114. end
  115.  
  116. print("Destination POS: ","X: "..DestX,"Z: "..DestZ)
  117. -- Strip Mine
  118. while CompletedTunnels < Tunnels do
  119.  PathFind(CurrentX,CurrentZ,DestX,DestZ) -- Current , Destination
  120. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement