jcoutie

Platform

Jan 26th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. print("**Platform Depositor**")
  4. print("Fill inventory!")
  5. print()
  6. print("Select distance forward:")
  7. distForward = read(input)
  8. term.clear()
  9. term.setCursorPos(1,1)
  10. print("**Platform Depositor**")
  11. print("Fill inventory!")
  12. print()
  13. print("Select distance right:")
  14. distRight = read(input)
  15. term.clear()
  16. term.setCursorPos(1,1)
  17. print("**Platform Depositor**")
  18. print("Running...")
  19.  
  20. -- Functions
  21.  
  22. local function fuel()
  23.   if turtle.getFuelLevel() < 1000  then
  24.     turtle.refuel(1)
  25.   end
  26. end
  27.  
  28. local function tMove(distance)
  29.   fuel()
  30.   for i=1,distance do
  31.     while turtle.forward() == false do
  32.       turtle.dig()
  33.       turtle.attack()
  34.       sleep(0.5)
  35.     end
  36.   end
  37. end
  38.  
  39. local function tDescend(distance)
  40.   for i=1,distance do
  41.     while turtle.down() == false do
  42.       turtle.digDown()
  43.       turtle.attackDown()
  44.       sleep(0.5)
  45.     end
  46.   end
  47. end
  48.  
  49. local function tAscend(distance)
  50.   for i=1,distance do
  51.     while turtle.up() == false do
  52.       turtle.digUp()
  53.       turtle.attackUp()
  54.       sleep(0.5)
  55.     end
  56.   end
  57. end
  58.  
  59. local function turnaround()
  60.   turtle.turnRight()
  61.   turtle.turnRight()
  62. end
  63.  
  64. local function tPlace()
  65.  if turtle.getItemCount(1) == 0 then
  66.   for i=2,15 do
  67.     turtle.select(i)
  68.     turtle.transferTo(1)
  69.   end
  70.  end
  71.  if turtle.getItemCount(1) == 0 then
  72.   term.clear()
  73.   term.setCursorPos(1,1)
  74.   print()
  75.   print()
  76.   print("Please refill inventory")
  77.   print()
  78.   print()
  79.   print("Press [ENTER] when ready")
  80.  end
  81.   turtle.select(1)
  82.   while turtle.placeDown() == false do
  83.     turtle.digDown()
  84.     turtle.attackDown()
  85.   end
  86. end
  87.  
  88. --Main Loop
  89. for i=1,distRight do
  90.   for j=1,distForward-1 do
  91.     tPlace()
  92.     tMove(1)
  93.   end
  94.   tPlace()
  95.   turnaround()
  96.   tMove(distForward-1)
  97.   turtle.turnLeft()
  98.   if i ~= distRight then
  99.     tMove(1)
  100.   end
  101.   turtle.turnLeft()
  102. end
Advertisement
Add Comment
Please, Sign In to add comment