Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Usage: place outside against the redwire
- -- Supply with inverted Lamps
- -- Supply with wires
- -- It will build lamps into the wall and place wires VERTICALLY
- -- ItemSupply:
- -- rows, starting with 1
- wireBlock = 1
- lampBlock = 2
- wireEnabled = true
- lampEnabled = true
- chestSlot = 0 -- ender chest: slot or 0 to disable DOESNT WORK HERE
- spawnerHeight = 2 * 2
- -- moves row to the first slow of the row
- -- at least keep Target supply in slot
- function moveSupplyRow(row, target)
- if not target then target = 16 end
- local start = (row-1)*4+2
- for i = start, 16 do
- if i ~= chestSlot then
- -- exit if enough items
- if turtle.getItemCount(start-1) >= target then break end
- turtle.select(i)
- turtle.transferTo(start-1)
- end
- end
- if chestSlot ~= 0 and turtle.getItemCount(start-1) < target then
- -- not enough items, fill from ender chest
- local direction
- local dirs = {"", "Up", "Down"}
- turtle.select(chestSlot)
- for d = 1, #dirs do
- direction = dirs[d]
- if turtle["place" .. direction]() then
- break
- end
- if d == 3 then
- error("Couldnt refill from chest")
- end
- end
- for i = 1, 15 do
- turtle["suck" .. direction]()
- os.sleep(0.2)
- end
- -- free enderchest slot
- turtle.select(chestSlot)
- turtle["drop" .. direction]()
- turtle["dig" .. direction]()
- end
- turtle.select(row2slot(row))
- end
- function row2slot(row)
- return (row-1)*4+1
- end
- function buildLevel()
- if lampEnabled then
- moveSupplyRow(lampBlock, 64)
- end
- if wireEnabled then
- moveSupplyRow(wireBlock, 64)
- end
- for i = 1, spawnerHeight do
- turtle[direction]()
- if i % 2 == 1 and i ~= spawnerHeight then
- if lampEnabled then
- turtle.forward()
- turtle.dig()
- turtle.select(row2slot(lampBlock))
- turtle.place()
- turtle.back()
- end
- end
- if wireEnabled then
- turtle.select(row2slot(wireBlock))
- turtle.place()
- end
- end
- end
- buildLevels = 17
- print("How many levels to build? Default: ".. tostring(buildLevels))
- buildLevels = tonumber(io.read()) or buildLevels
- print("--> ".. tostring(buildLevels) .. " levels")
- print("Direction? 'up' or 'down'. Default: 'up'")
- direction = io.read()
- if direction == "" then
- direction = "up"
- end
- -- move away from wall after placement
- for n = 1, buildLevels do
- buildLevel()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement