Advertisement
VADemon

SpawnerVerticalBuilder

Oct 29th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1.  
  2. -- ItemSupply:
  3. -- rows, starting with 1
  4. stoneBlock = 1
  5. dirtBlock = 2
  6. redstoneBlock = 3
  7. fanBlock = 4
  8.  
  9. spawnerHeight = 1
  10.  
  11. -- moves row to the first slow of the row
  12. -- at least keep Target supply in slot
  13. function moveSupplyRow(row, target)
  14.     if not target then target = 16 end
  15.    
  16.     local start = (row-1)*4+2
  17.     for i = start, (row)*4 do
  18.         -- exit if enough items
  19.         if turtle.getItemCount(start-1) >= target then break end
  20.        
  21.         turtle.select(i)
  22.         turtle.transferTo(start-1)
  23.     end
  24. end
  25.  
  26. function row2slot(row)
  27.     return (row-1)*4+1
  28. end
  29.  
  30. function buildLevel()
  31.     -- place dirt
  32.     if dirtEnabled then
  33.         moveSupplyRow(dirtBlock)
  34.         turtle.select(row2slot(dirtBlock))
  35.         turtle.place()
  36.     end
  37.     -- move up
  38.     turtle.up()
  39.     --place stone brick below
  40.     moveSupplyRow(stoneBlock)
  41.     turtle.select(row2slot(stoneBlock))
  42.     turtle.placeDown()
  43.     -- place fan
  44.     if fanEnabled then
  45.         turtle.forward(); turtle.forward(); turtle.turnLeft(); turtle.turnLeft()
  46.         moveSupplyRow(fanBlock)
  47.         turtle.select(row2slot(fanBlock))
  48.         turtle.place()
  49.         --move up and back to wall position
  50.         turtle.up()
  51.         turtle.turnLeft(); turtle.turnLeft(); turtle.back(); turtle.back()
  52.     else
  53.         turtle.up()
  54.     end
  55.    
  56.     -- place redstone block below?
  57.     if redstoneEnabled then
  58.         moveSupplyRow(redstoneBlock)
  59.         turtle.select(row2slot(redstoneBlock))
  60.         turtle.placeDown()
  61.     end
  62.    
  63.     turtle.select(row2slot(stoneBlock))
  64.     -- Which height?
  65.     -- i = 1 -> 2 blocks height
  66.     -- i = 2 -> 3 blocks height
  67.     -- ...
  68.     for i = 1, spawnerHeight do
  69.         -- place stone brick
  70.         turtle.up()
  71.         turtle.placeDown()
  72.     end
  73.  
  74.     -- place floor of the next level
  75.     turtle.place()
  76.    
  77.     turtle.up()
  78.     turtle.placeDown()
  79. end
  80.  
  81. buildLevels = 1
  82. fanEnabled = false
  83. redstoneEnabled = false
  84. stoneEnabled = true
  85. dirtEnabled = true
  86.  
  87. print("How many levels to build? Default: 1")
  88. buildLevels = tonumber(io.read()) or 1
  89. print("--> ".. tostring(buildLevels) .. " levels")
  90.  
  91. print("Build redstone? Y/n")
  92. redstoneEnabled = false
  93. if string.lower(io.read()) == "n" then
  94.     redstoneEnabled = false
  95. else
  96.     redstoneEnabled = true
  97. end
  98.  
  99. print("--> Build redstone: ".. tostring(redstoneEnabled))
  100.  
  101. print("Build fans? y/N")
  102. fanEnabled = string.lower(io.read()) == "y" and true or false
  103. print("--> Build fans: ".. tostring(fanEnabled))
  104.  
  105. for n = 1, buildLevels do
  106.     buildLevel()
  107. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement