Advertisement
djPtica

sideTunel (no torches)

May 16th, 2015
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.01 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. provjeraSkrinje()
  126. print("")
  127. print("Zapocinjem razgranati tunel.")
  128. if duljina>0 then
  129.    for i=1, duljina do
  130.       kopaj()
  131.       if i%3==0 then
  132.          kopajStrane()
  133.       end
  134.       provjeraFull()
  135.    end
  136.    turtle.turnLeft()
  137.    turtle.turnLeft()
  138.    povratak(duljina)
  139.    print("Tunel uspjesno napravljen!")
  140. else
  141.    print("Nije zadana ili pogresno zadana duljina. (e.g.: sideTunel 15)")
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement