Advertisement
Guest User

newslave

a guest
Jul 28th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.64 KB | None | 0 0
  1. rednet.open("right")
  2. local xPos, yPos, zPos = nil                          
  3. local heading = 1
  4. local xSet,ySet,zSet = nil
  5. local distance = nil
  6. local blockplacecounter = nil
  7. local selectedslot = 1
  8. local Aktuellx,Aktuelly,Aktuellz = nil
  9. local durchgaenge = 0
  10. local block_mine_counter = 0
  11. local Startx,Starty,Startz = nil
  12. --id,message = rednet.receive()
  13. --Steuercode
  14. --bedrockmining()
  15. --if message == "ebnen" then
  16. --  gebiet_ebnen()
  17. --end
  18. --if message == "bedrock" then
  19. --  bedrock_mining()
  20. --end
  21. --functions
  22. function getPosition()
  23.   xPos, yPos, zPos = gps.locate()
  24.   return xPos,yPos,zPos
  25. end
  26. function setPosition()
  27.   xSet,ySet,zSet=getPosition()
  28. end
  29. function getHeading()
  30.   x1,y1,z1=getPosition()
  31.   forward()
  32.   forward()
  33.   x2,y2,z2=getPosition()
  34.   back()
  35.   back()
  36.   left()
  37.   forward()
  38.   forward()
  39.   x3,y3,z3=getPosition()
  40.   back()
  41.   back()
  42.   right()
  43.   if (x2-x1)>=-1 then
  44.     heading=1
  45.   elseif (x2-x1)>=1 then
  46.     heading=3
  47.   elseif (z3-z1)>=1 then
  48.     heading=0
  49.   elseif (z3-z1)>=-1 then
  50.     heading=2
  51.   end
  52.  
  53.   while not(heading==1) do
  54.     right()
  55.   end
  56. end
  57. function setworkArea(blocks)
  58.   distance = blocks
  59. end
  60. function forward()
  61.   turtle.forward()
  62. end
  63. function down()
  64.   turtle.down()
  65.   Aktuellz = Aktuellz -1
  66. end
  67. function up()
  68.   turtle.up()
  69.   Aktuellz = Aktuellz +1
  70. end
  71. function Slotleer()
  72.   if blockplacecounter == 64 then
  73.     turtle.select(selectedslot+1)
  74.     selectedslot = selectedslot +1
  75.     blockplacecounter = 0
  76.   end
  77. end
  78. function right()
  79.   if heading==1 then
  80.   heading = 2
  81.   elseif heading == 2 then
  82.   heading = 3
  83.   elseif heading == 3 then
  84.   heading = 0
  85.   elseif heading == 0 then
  86.   heading = 1
  87.   end
  88.   turtle.turnRight()
  89. end
  90. function left()
  91.   if heading == 1 then
  92.     heading = 0
  93.   elseif heading == 0 then
  94.     heading= 3
  95.   elseif heading == 3 then
  96.     heading = 2
  97.   elseif heading == 2 then
  98.     heading = 1
  99.   end
  100.   turtle.turnLeft()
  101. end
  102. function back()
  103.   turtle.back()
  104. end
  105. function dig()
  106.   turtle.dig()
  107. end
  108. function digDown()
  109.   turtle.digDown()
  110. end
  111. function digUp()
  112.   turtle.digUp()
  113. end
  114. function placeUnder()
  115.   turtle.placeDown()
  116.   if blockplacecounter == nil then
  117.     blockplacecounter = 1
  118.   end
  119.   blockplacecounter = blockplacecounter +1
  120. end
  121. function detectDown()
  122.   detectionDown =  turtle.detectDown()
  123.   return detectionDown
  124. end
  125. function detect()
  126.   detectionFront = turtle.detect()
  127.   return detectionFront
  128. end
  129. function compareTo()
  130.   comparision =  turtle.compareTo(2)
  131.   return comparision
  132. end
  133. function block_unten_ersetzen()
  134.   if detectDown() then
  135.     digDown()
  136.     placeUnder()
  137.   else
  138.     placeUnder()
  139.   end
  140. end
  141. function block_vorne_entfernen()
  142.   if detect() then
  143.     dig()
  144.   end
  145. end  
  146. --
  147. --function bedrockmining()
  148.   Startx,Starty,Startz = getPosition()
  149.   --Aktuellx,Aktuelly,Aktuellz = getPosition()
  150.   --Aktuellx,Aktuelly,Aktuellz = Startx,Starty,Startz
  151.   durchgaenge=0
  152.   while not(message=="end") do
  153.     --runter auf level 12
  154.     if not(Aktuellz==12) then
  155.       while (Aktuellz>=12) do
  156.         Aktuellx,Aktuelly, Aktuellz = getPosition()
  157.         if turtle.detectDown() then
  158.           digDown()
  159.           down()
  160.         else
  161.           down()
  162.         end
  163.       end
  164.     end
  165.     --Auf Ebene 12 minen
  166.     block_mine_counter = 0
  167.     while block_mine_counter <=20 do
  168.       --block_vorne_entfernen()
  169.       if (turtle.detect()) then
  170.         dig()
  171.         forward()
  172.       end
  173.       if not (turtle.detect()) then
  174.       forward()
  175.       end
  176.       block_mine_counter = block_mine_counter +1
  177.        
  178.     end
  179.     right()
  180.     block_vorne_entfernen()
  181.     forward()
  182.     block_vorne_entfernen()
  183.     forward()
  184.     right()
  185.     block_mine_counter = 0
  186.     durchgaenge=durchgaenge +1
  187.     if durchgaenge == 3 then
  188.       while not(Aktuellz==Startz) do
  189.         digUp()
  190.         up()
  191.       end
  192.     end
  193.   end
  194. --end
  195. --
  196. function gebiet_ebnen()
  197. setPosition()
  198. setworkArea(15)
  199. --getHeading()
  200. --
  201.  
  202. while not (message=="end") do
  203.   --Position bestimmen
  204.   x,y,z =getPosition()
  205.   --Ende Position
  206.  if (z>=zSet-distance) and (z<=zSet+distance) then
  207.   Slotleer()
  208.   if heading == 1 then
  209.     if x >= (xSet-distance) then
  210.       block_unten_ersetzen()
  211.       block_vorne_entfernen()
  212.       forward()
  213.     else
  214.       left()
  215.       block_unten_ersetzen()
  216.       block_vorne_entfernen()
  217.       forward()
  218.       left()
  219.     end
  220.   end
  221.   if heading == 3 then
  222.     if x<= (xSet) then
  223.       block_unten_ersetzen()
  224.       block_vorne_entfernen()
  225.       forward()
  226.     else
  227.       right()
  228.       block_unten_ersetzen()
  229.       block_vorne_entfernen()
  230.       forward()
  231.       right()
  232.     end
  233.   end
  234.  end
  235. --if not (turtle.compareTo(2)) and turtle.detect() then
  236.  
  237. end
  238. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement