Advertisement
Guest User

upanddown

a guest
Jun 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.03 KB | None | 0 0
  1. r = 1
  2.  
  3.  
  4.  
  5.  
  6. dropAll = function()
  7.   for i=2,16 do
  8.     turtle.select(i)
  9.     turtle.dropUp()
  10.   end
  11.   turtle.select(1)
  12.    turtle.suckUp()
  13.    turtle.refuel()
  14.  
  15. end
  16.  
  17. schachtGraben = function()
  18.   hoehe= 0
  19.  
  20.   while true do
  21.     if turtle.detectDown() then
  22.        turtle.digDown()
  23.        if turtle.detectDown() then
  24.          break
  25.        end
  26.     end
  27.        
  28.     hoehe = hoehe+1
  29.     turtle.down()
  30.   end
  31.  
  32.   for ii=1,hoehe do
  33.     turtle.digUp()
  34.     turtle.up()      
  35.   end
  36. end
  37.  
  38.  
  39. kreis = function(r)
  40.   tx = r
  41.   ty = r
  42.   s = 0
  43.   while true do
  44.     if tx > 0 then
  45.       turtle.turnRight()
  46.       for i=1,tx do
  47.         turtle.dig()
  48.         turtle.forward()
  49.       end
  50.       turtle.turnLeft()
  51.     end
  52.    
  53.     if tx < 0 then
  54.       turtle.turnLeft()
  55.       for i=1, -tx do
  56.         turtle.dig()
  57.         turtle.forward()
  58.       end
  59.       turtle.turnRight()
  60.     end
  61.    
  62.    if ty > 0 then
  63.      for i=1,ty do
  64.        turtle.dig()
  65.        turtle.forward()
  66.      end
  67.    end
  68.    
  69.    if ty < 0 then
  70.      turtle.turnLeft()
  71.      turtle.turnLeft()
  72.      for i=1, -ty do
  73.        turtle.dig()
  74.        turtle.forward()
  75.      end
  76.      turtle.turnRight()
  77.      turtle.turnRight()
  78.    end
  79.    
  80.    schachtGraben()    
  81.  
  82.    if ty > 0 then
  83.      for i=1, ty do turtle.back() end
  84.    end
  85.    
  86.    if ty < 0 then
  87.      for i=1, -ty do turtle.forward() end
  88.    end  
  89.                      
  90.    if tx > 0 then
  91.      turtle.turnLeft()
  92.      for i=1, tx do turtle.forward() end
  93.      turtle.turnRight()
  94.    end
  95.    
  96.    if tx < 0 then
  97.      turtle.turnRight()
  98.      for i=1,-tx do turtle.forward() end
  99.      turtle.turnLeft()
  100.    end
  101.        
  102.    dropAll()
  103.    
  104.    if s == 0 then
  105.      ty = ty-1
  106.      if ty == -r then
  107.        s= 1
  108.      end
  109.    elseif s ==1 then
  110.      tx = tx-1
  111.      if tx == -r then
  112.        s= 2
  113.      end
  114.    elseif s== 2 then
  115.      ty = ty+1
  116.      if ty == r then
  117.        s= 3
  118.      end
  119.    elseif s== 3 then
  120.      tx = tx+1
  121.      if tx == r then
  122.        break
  123.      end
  124.    end  
  125.   end
  126. end  
  127.    
  128. for i=r,2 do
  129.   kreis(i)
  130. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement