Advertisement
jakikoske

jannis test2

Dec 13th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. function MoveForward()
  2.     while(turtle.forward() == false) do
  3.         turtle.dig()
  4.     end
  5. end
  6.  
  7. function MoveDown()
  8.     while(turtle.down() == false) do
  9.         turtle.digDown()
  10.     end
  11. end
  12.  
  13. function MoveUp()
  14.     while(turtle.up() == false) do
  15.         turtle.digUp()
  16.     end
  17. end
  18.  
  19.  
  20. function PlaceUp()
  21.     turtle.placeUp()
  22. end
  23.  
  24. function TurnRight()
  25.     turtle.turnRight()
  26. end
  27.  
  28. function TurnLeft()
  29.     turtle.turnLeft()
  30. end
  31.  
  32. function Place1stChunk()
  33.     MoveDown()
  34.     turtle.select(1)
  35.     PlaceUp()
  36.     TurnRight()
  37.     MoveForward()
  38.     MoveUp()
  39.     TurnRight()
  40.     Dig()
  41.     TurnRight()
  42.     TurnRight()
  43.     MoveForward()
  44.     TurnLeft()
  45.     MoveForward()
  46.     TurnRight()
  47. end
  48.  
  49.  
  50. function Go()
  51.     for i = 1 , 14 do
  52.         MoveForward()
  53.     end
  54. end
  55.  
  56. function Place()
  57.     turtle.place()
  58. end
  59.  
  60. function Dig()
  61.     turtle.dig()
  62. end
  63.  
  64. function Place2ndChunk()
  65.     TurnRight()
  66.     MoveForward()
  67.     TurnLeft()
  68.     Dig()
  69.     turtle.select(1)
  70.     Place()
  71.     TurnLeft()
  72.     MoveForward()
  73.     TurnLeft()
  74.     TurnLeft()
  75.     Place()
  76.     TurnRight()
  77. end
  78.  
  79. function RetrieveChunk()
  80.     Go()
  81.     Dig()
  82.     TurnLeft()
  83.     TurnLeft()
  84.     MoveForward()
  85.     Go()
  86. end
  87.  
  88. function DigUp()
  89.     while(turtle.detectUp() == true) do
  90.         turtle.digUp()
  91.     end
  92. end
  93.  
  94. function DumpInv()
  95.     DigUp()
  96.     turtle.select(2)
  97.     turtle.placeUp()
  98.     for i = 3,15 do
  99.         turtle.select(i)
  100.         turtle.dropUp()
  101.     end
  102.     turtle.select(2)
  103.     turtle.digUp()
  104.     turtle.suckUp()
  105. end
  106.  
  107. function GetFuelFromChest()
  108.   turtle.select(2)
  109.   DigUp()
  110.   turtle.placeUp()
  111.   turtle.select(16)
  112.   turtle.dropUp()
  113.   turtle.suckUp()
  114.   turtle.select(2)
  115.   turtle.digUp()
  116.   turtle.suckUp()
  117. end
  118.  
  119. function CheckFuel()
  120.   if turtle.getFuelLevel() <= 20 then
  121.     turtle.select(16)
  122.     turtle.refuel(5)
  123.   end
  124.   if turtle.getFuelLevel() <= 1 then
  125.     GetFuelFromChest()
  126.     CheckFuel()
  127.   end
  128.   return true  
  129. end
  130.  
  131. function main()
  132.     while(true) do
  133.         CheckFuel()
  134.         Place1stChunk()
  135.         Go()
  136.         Place2ndChunk()
  137.         RetrieveChunk()
  138.         DumpInv()
  139.     end
  140. end
  141.  
  142. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement