Advertisement
Pinkishu

alvBuilder

Feb 22nd, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.07 KB | None | 0 0
  1. local alvearySlots = {1,3}
  2. local slabSlots = {2}
  3. local types = {alveary = alvearySlots, slabs = slabSlots}
  4. local layerTypes = { "alveary", "alveary", "alveary", "slabs" }
  5. local turnAltB = false
  6.  
  7. local function selectSlot(type)
  8.     local slotsForType = types[type]
  9.     for _,v in pairs(slotsForType) do
  10.         if turtle.getItemCount(v) > 0 then
  11.             turtle.select(v)
  12.             return v
  13.         end
  14.     end
  15.     return nil
  16. end
  17.  
  18. local function placeDown(type)
  19.     selectSlot(type)
  20.     while not turtle.placeDown() do sleep(1) end
  21. end
  22. local function placeUp(type)
  23.     selectSlot(type)
  24.     while not turtle.placeUp() do sleep(1) end
  25. end
  26. local function place(type)
  27.     selectSlot(type)
  28.     while not turtle.place() do sleep(1) end
  29. end
  30.  
  31. local function goForward()
  32.     while not turtle.forward() do sleep(1) end
  33. end
  34.  
  35. local function goBack()
  36.     while not turtle.back() do sleep(1) end
  37. end
  38.  
  39. local function goUp()
  40.     while not turtle.up() do sleep(1) end
  41. end
  42.  
  43. local function goDown()
  44.     while not turtle.down() do sleep(1) end
  45. end
  46.  
  47. local function buildSlabRow(type,length)
  48.     for i=1,length,1 do
  49.         placeDown(type)
  50.         if i ~= length then goForward() end
  51.     end
  52. end
  53.  
  54. local function turnAlt(toggle)
  55.     if not turnAltB then turtle.turnRight()
  56.     else turtle.turnLeft() end
  57.     if toggle then turnAltB = not turnAltB end
  58. end
  59.  
  60. local function buildAlvRow(type,length)
  61.     local slot = selectSlot(type)
  62.     for i=1,length,1 do
  63.         placeUp(type)
  64.         placeDown(type)
  65.         if i == length then
  66.             turnAlt()
  67.         end
  68.         goBack()
  69.         place(type)
  70.     end
  71. end
  72.  
  73.  
  74. --[[
  75. local function buildAlveary()
  76.     turnAltB = false
  77.     for layer=1,4,1 do
  78.         goUp()
  79.         for rows=1,3,1 do
  80.             buildRow(layerTypes[layer],3)
  81.             if rows ~= 3 then
  82.                 turnAlt()
  83.                 goForward()
  84.                 turnAlt(true)
  85.             end
  86.         end
  87.         if layer ~= 4 then
  88.             turnAlt()
  89.             turnAlt()
  90.         end
  91.     end
  92. end]]
  93.  
  94. local function buildAlveary()
  95.     goUp()
  96.     turnAltB = false
  97.     turtle.turnRight()
  98.     turtle.turnRight()
  99.     for i=1,3,1 do
  100.         buildAlvRow("alveary",3)
  101.         turnAlt(true)
  102.     end
  103.     for i=1,3,1 do goUp() end
  104.     turnAltB = false
  105.     turtle.turnLeft()
  106.     goForward()
  107.     turtle.turnLeft()
  108.     for i=1,3,1 do
  109.         buildSlabRow("slabs",3)
  110.         if i ~= 3 then
  111.             turnAlt()
  112.             goForward()
  113.             turnAlt(true)
  114.         end
  115.     end
  116. end
  117.  
  118. local function buildAlvearies()
  119.     for p=1,2,1 do
  120.         buildAlveary()
  121.         turtle.turnLeft()  
  122.         turtle.turnLeft()
  123.         for i=1,6,1 do goForward() end
  124.         for i=1,4,1 do goDown() end
  125.         buildAlveary()
  126.         if p ~=2 then
  127.             turtle.turnLeft()
  128.             for i=1,6,1 do goForward() end
  129.             turtle.turnRight()
  130.             for i=1,6,1 do goForward() end
  131.             turtle.turnRight()
  132.             turtle.turnRight()
  133.             for i=1,4,1 do goDown() end
  134.         end
  135.     end
  136. end
  137.  
  138. buildAlvearies()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement