Advertisement
djPtica

sideTunel

Feb 3rd, 2013
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.14 KB | None | 0 0
  1. --sideTunel by djPtica v0.1.4
  2. --SETUP
  3. --put turtle in front of your desired tunel on head level, not ground level
  4. --put chests in slot 15
  5. --put torches in slot 16
  6. --make sure that slot 14 is empty
  7.  
  8. local tArgs = {...}
  9. local duljina = 0
  10. duljina = tonumber(tArgs[1])
  11.  
  12. function kopaj()
  13.    turtle.dig()
  14.    while not turtle.forward() do
  15.       turtle.dig()
  16.       turtle.attack()
  17.    end
  18.    turtle.digDown()
  19. end
  20.  
  21. function kopajStrane()
  22.    turtle.turnLeft()
  23.    for o=1, 4 do
  24.       kopaj()
  25.    end
  26.    turtle.turnLeft()
  27.    turtle.turnLeft()
  28.    povratak(4)
  29.    for o=1, 4 do
  30.       kopaj()
  31.    end
  32.    turtle.turnLeft()
  33.    turtle.turnLeft()
  34.    povratak(4)
  35.    turtle.turnRight()
  36. end
  37.  
  38. function povratak(dist)
  39.    for i=1, dist do
  40.       while not turtle.forward() do
  41.          turtle.attack()
  42.       end
  43.    end
  44. end
  45.  
  46. function provjeraBaklje()
  47.    torch = duljina / 5
  48.    torch = math.floor(torch)
  49.    while true do
  50.       j = turtle.getItemCount(16)
  51.       if j<torch then
  52.          print("Nedovoljno baklji.")
  53.          print("Stavi jos ", torch-j, " baklji u slot 16. (donji desni slot)")
  54.       else
  55.          print("Baklje: OK")
  56.          break
  57.       end
  58.       sleep(3)
  59.    end
  60. end
  61.  
  62. function provjeraGorivo()
  63.    gorivo = duljina * 20
  64.    while true do
  65.       k = turtle.getFuelLevel()
  66.       if k<gorivo then
  67.          print("Nedovoljno goriva.")
  68.          print("Stavi gorivo (coal, wood) u slot 1. (gornji lijevi slot)")
  69.          l=0
  70.          l = turtle.getItemCount(1)
  71.          turtle.refuel(l)
  72.       else
  73.          print("Gorivo: OK")
  74.          break
  75.       end
  76.       sleep(3)
  77.    end
  78. end
  79.  
  80. function provjeraSkrinje()
  81.    chest = duljina / 10
  82.    chest = math.floor(chest)
  83.    while true do
  84.       p = turtle.getItemCount(15)
  85.       if p<chest then
  86.          print("Nedovoljno skrinja.")
  87.          print("Stavi jos ", chest-p, " skrinja u slot 15. (donji treci slot)")
  88.       else
  89.          print("Skrinje: OK")
  90.          break
  91.       end
  92.       sleep(3)
  93.    end
  94. end
  95.  
  96. function provjeraFull()
  97.    if turtle.getItemCount(14)>0 then
  98.       turtle.select(15)
  99.       if turtle.placeDown() then
  100.          for s=1, 14 do
  101.             turtle.select(s)
  102.             turtle.dropDown()
  103.          end
  104.       else
  105.          turtle.turnLeft()
  106.          turtle.turnLeft()
  107.          while not turtle.forward() do
  108.             turtle.attack()
  109.          end
  110.          turtle.turnLeft()
  111.          turtle.turnLeft()
  112.          turtle.placeDown()
  113.          for s=1, 14 do
  114.             turtle.select(s)
  115.             turtle.dropDown()
  116.          end
  117.       end
  118.       turtle.forward()
  119.    end
  120.    turtle.select(1)
  121. end
  122.  
  123. --GLAVNI PROGRAM
  124. provjeraGorivo()
  125. provjeraBaklje()
  126. provjeraSkrinje()
  127. print("")
  128. print("Zapocinjem razgranati tunel.")
  129. if duljina>0 then
  130.    for i=1, duljina do
  131.       kopaj()
  132.       if i%3==0 then
  133.          kopajStrane()
  134.       end
  135.       if i%5==0 then
  136.          turtle.select(16)
  137.          turtle.placeDown()
  138.          turtle.select(1)
  139.       end
  140.       provjeraFull()
  141.    end
  142.    turtle.turnLeft()
  143.    turtle.turnLeft()
  144.    povratak(duljina)
  145.    print("Tunel uspjesno napravljen!")
  146. else
  147.    print("Nije zadana ili pogresno zadana duljina. (e.g.: sideTunel 15)")
  148. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement