Advertisement
Fulgar

parte 2 Iron golem farm

Apr 4th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local t = turtle
  2. local c = true
  3.  
  4. local square = 8
  5. local gira = "right"
  6. local altezza = 3
  7. altezza = altezza + 1 -- Aumento di 1 perché piazzo blocchi anche a livello pavimento
  8. local lati = 4 -- Lati del quadrato
  9. local inutile = 0
  10. local conta = 1
  11.  
  12. local slot = 16
  13.  
  14. local function selectSlot(n)
  15.     t.select(1)
  16.     c = 1
  17.     for i = 1,n do
  18.         if turtle.getItemCount(c) == 0 then
  19.             c = c + 1
  20.             if c == 17 then
  21.                 print("Materiali finiti. In attesa di essere rifornita di materiali. Il controllo ripartira' tra 10 secondi")
  22.                 c = 1
  23.                 i = 1
  24.                 sleep(10)
  25.             end
  26.             turtle.select(c)
  27.         end
  28.     end
  29. end
  30.    
  31.  
  32. local function piazza(n)
  33.     selectSlot(slot)
  34.     for i = 1,n do
  35.         -- Se il quadrato e' 29, 30 ,35 o 36 allora non piazzo il blocco
  36.         conta = conta +1
  37.         selectSlot(slot)
  38.         t.dig()
  39.         t.forward()
  40.         if conta == 29 or conta == 30 or conta == 37 or conta == 38 then
  41.             inutile = inutile +1
  42.         else
  43.             t.placeDown()
  44.         end
  45.     end
  46. end
  47.  
  48. local function lato(n)
  49.     selectSlot(slot)
  50.     n = n + 1
  51.     for i = 1,n do
  52.         selectSlot(slot)
  53.         if n == 4 then
  54.             inutile = inutile +1
  55.         else
  56.             t.placeDown()
  57.         end
  58.         t.dig()
  59.         t.forward()
  60.     end
  61. end
  62.  
  63. while c do
  64.     t.select(1)
  65.     selectSlot(slot)
  66.     -- Pavimentazione
  67.     for i2 = 1,square do
  68.         piazza(square)
  69.         t.dig()
  70.         t.forward()
  71.         if gira == "right" then
  72.             t.turnRight()
  73.             t.dig()
  74.             t.forward()
  75.             t.turnRight()
  76.             gira = "left"
  77.         else
  78.             t.turnLeft()
  79.             t.dig()
  80.             t.forward()
  81.             t.turnLeft()
  82.             gira = "right"
  83.         end
  84.     end
  85.  
  86.  
  87.     -- Lato
  88.     for i5 = 1,altezza do
  89.  
  90.         for i4 = 1,lati do
  91.             lato(square)
  92.             if gira == "right" then -- deve cambiare senso
  93.                 t.turnLeft()
  94.             else
  95.                 t.turnRight()
  96.             end
  97.         end
  98.            
  99.         if i5 == altezza then
  100.  
  101.             if gira == "right" then -- deve cambiare senso
  102.                 t.turnLeft()
  103.             else
  104.                 t.turnRight()
  105.             end
  106.  
  107.             for i = 1,square do
  108.                 t.dig()
  109.                 t.forward()
  110.             end
  111.            
  112.             if gira == "right" then
  113.                 t.turnRight()
  114.             else
  115.                 t.turnLeft()
  116.             end
  117.             t.digUp()
  118.             t.up()
  119.             t.digUp()
  120.             t.up()
  121.  
  122.         else
  123.             t.digUp()
  124.             t.up()
  125.  
  126.         end
  127.  
  128.     end
  129.  
  130.     -- Tetto
  131.     conta = 1
  132.     for i2 = 1,square do
  133.         piazza(square)
  134.         t.dig()
  135.         t.forward()
  136.         if gira == "right" then
  137.             t.turnRight()
  138.             t.dig()
  139.             t.forward()
  140.             t.turnRight()
  141.             gira = "left"
  142.         else
  143.             t.turnLeft()
  144.             t.dig()
  145.             t.forward()
  146.             t.turnLeft()
  147.             gira = "right"
  148.         end
  149.     end
  150.  
  151.     c = false
  152. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement