Guest User

Untitled

a guest
Oct 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.51 KB | None | 0 0
  1. local sSnow = 1
  2. local sPlate = 11
  3. local sRep = 13
  4. local sPist = 15
  5.  
  6. function fwd()
  7.   while not turtle.forward() do turtle.attack() end
  8. end
  9.  
  10. function placeSnow(dir)
  11.   while turtle.getItemCount(sSnow) <= 0 and sSnow <= 16 do
  12.     sSnow = sSnow + 1
  13.   end
  14.   if sSnow >= sPlate then
  15.     error("Out of snow")
  16.   end
  17.  
  18.   turtle.select(sSnow)
  19.   if dir == -1 then
  20.     turtle.placeDown()
  21.   elseif dir == 1 then
  22.     turtle.placeUp()
  23.   else
  24.     turtle.place()
  25.   end
  26. end
  27.  
  28. function placePlate(dir)
  29.   while turtle.getItemCount(sPlate) <= 0 and sPlate <= 16 do
  30.     sPlate = sPlate + 1
  31.   end
  32.   if sPlate >= sRep then
  33.     error("Out of pressure plates")
  34.   end
  35.  
  36.   turtle.select(sPlate)
  37.   if dir == -1 then
  38.     turtle.placeDown()
  39.   elseif dir == 1 then
  40.     turtle.placeUp()
  41.   else
  42.     turtle.place()
  43.   end
  44. end
  45.  
  46. function placeRep(dir)
  47.   while turtle.getItemCount(sRep) <= 0 and sRep <= 16 do
  48.     sRep = sRep + 1
  49.   end
  50.   if sRep >= sPist then
  51.     error("Out of repeaters")
  52.   end
  53.  
  54.   turtle.select(sRep)
  55.   if dir == -1 then
  56.     turtle.placeDown()
  57.   elseif dir == 1 then
  58.     turtle.placeUp()
  59.   else
  60.     turtle.place()
  61.   end
  62. end
  63.  
  64. function placePist(dir)
  65.   while turtle.getItemCount(sPist) <= 0 and sPist <= 16 do
  66.     sPist = sPist + 1
  67.   end
  68.   if sPist > 16 then
  69.     error("Out of pistons")
  70.   end
  71.  
  72.   turtle.select(sPist)
  73.   if dir == -1 then
  74.     turtle.placeDown()
  75.   elseif dir == 1 then
  76.     turtle.placeUp()
  77.   else
  78.     turtle.place()
  79.   end
  80. end
  81.  
  82. function segment()
  83.   for i = 1, 13 do
  84.     placeSnow(-1)
  85.     if i ~= 13 then fwd() end
  86.   end
  87.  
  88.   turtle.turnRight()
  89.   fwd()
  90.   turtle.turnRight()
  91.  
  92.   for i = 1, 13 do
  93.     turtle.turnRight()
  94.     fwd()
  95.     fwd()
  96.     fwd()
  97.     placePist(1)
  98.     turtle.back()
  99.     placeSnow(-1)
  100.     placeSnow(0)
  101.     placeSnow(1)
  102.     turtle.back()
  103.     placeRep(0)
  104.     turtle.back()
  105.     placePlate(0)
  106.     turtle.turnLeft()
  107.     fwd()
  108.   end
  109.  
  110.   turtle.turnLeft()
  111.   turtle.back()
  112.   turtle.down()
  113.  
  114.   for i = 1, 4 do
  115.     placeSnow(1)
  116.     fwd()
  117.   end
  118. end
  119.  
  120. args = {...}
  121. times = nil
  122. if #args >= 1 then
  123.   times = tonumber(args[1])
  124. end
  125. if times == nil then times = 1 end
  126.  
  127. for t = 1, times do
  128.   turtle.up()
  129.  
  130.   segment()
  131.  
  132.   turtle.back()
  133.   turtle.turnLeft()
  134.   fwd()
  135.   turtle.up()
  136.  
  137.   for i = 1, 12 do
  138.     fwd()
  139.   end
  140.  
  141.   turtle.turnRight()
  142.   turtle.turnRight()
  143.  
  144.   segment()
  145.  
  146.   turtle.up()
  147.   turtle.up()
  148.   turtle.up()
  149.   turtle.turnLeft()
  150.  
  151.   for i = 1, 13 do
  152.     fwd()
  153.   end
  154.  
  155.   turtle.turnLeft()
  156.   fwd()
  157.   turtle.turnLeft()
  158.   turtle.up()
  159. end
Add Comment
Please, Sign In to add comment