Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Usage: place turtle above the level of AE interfaces at a corner of an empty row
- -- Supply with Interfaces
- -- Supply with Assemblers
- -- Supply with acceleratorUpgrades
- -- It will build AE2 crafting grid automatically
- -- ItemSupply:
- -- rows, starting with 1
- interfaceBlock = 1
- assemblerBlock = 2
- acceleratorUpgrade = 3
- acceleratorEnabled = true
- -- for accelerators
- chestSlot = 16 -- ender chest: slot or 0 to disable
- -- 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 putUpgrades(side, n)
- if not acceleratorEnabled then return end
- side = side or ""
- n = n or 5
- if turtle.getItemCount(row2slot(acceleratorUpgrade)) < 11 then
- moveSupplyRow(acceleratorUpgrade, 64)
- end
- turtle.select(row2slot(acceleratorUpgrade))
- turtle["drop" .. side](n)
- end
- function buildLevel()
- if acceleratorEnabled then
- moveSupplyRow(acceleratorUpgrade, 64)
- end
- moveSupplyRow(assemblerBlock, 64)
- -- assembler Row
- for i = 1, rowLength do
- turtle.forward()
- turtle.select(row2slot(assemblerBlock))
- turtle.placeDown()
- putUpgrades("Down")
- turtle.forward()
- -- dont move outside
- if i ~= rowLength then
- turtle.forward()
- end
- end
- -- interface row backwards
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- moveSupplyRow(interfaceBlock, 64)
- moveSupplyRow(assemblerBlock, 64)
- for i = 1, rowLength do
- if acceleratorEnabled then
- moveSupplyRow(acceleratorUpgrade, 64)
- end
- turtle.select(row2slot(assemblerBlock))
- turtle.placeDown()
- putUpgrades("Down")
- turtle.back()
- turtle.select(row2slot(assemblerBlock))
- turtle.placeUp()
- putUpgrades("Up")
- turtle.select(row2slot(interfaceBlock))
- turtle.placeDown()
- turtle.back()
- turtle.select(row2slot(assemblerBlock))
- turtle.place()
- putUpgrades("")
- turtle.placeDown()
- putUpgrades("Down")
- turtle.back()
- end
- -- assembler row 2
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- moveSupplyRow(assemblerBlock, 64)
- -- assembler Row
- for i = 1, rowLength do
- turtle.forward()
- turtle.select(row2slot(assemblerBlock))
- turtle.placeDown()
- putUpgrades("Down")
- turtle.forward()
- -- dont move outside
- if i ~= rowLength then
- turtle.forward()
- end
- end
- for i = 1, (rowLength*3 - 1) do
- turtle.back()
- end
- end
- buildLevels = 1
- rowLength = 6
- print("Row Length? Default: ".. tostring(rowLength))
- rowLength = tonumber(io.read()) or rowLength
- print("--> ".. tostring(rowLength) .. " interfaces length")
- print("How many rows to build? Default: ".. tostring(buildLevels))
- buildLevels = tonumber(io.read()) or buildLevels
- print("--> ".. tostring(buildLevels) .. " levels")
- print("Direction? 'Left' or 'Right'. Default: 'Left'")
- direction = io.read()
- if direction == "" then
- direction = "Left"
- end
- print("--> " .. tostring(direction))
- print("Use accelerators? Y/n Default: yes")
- acceleratorEnabled = string.lower(io.read()) == "y" and true or false
- print("--> ".. tostring(acceleratorEnabled))
- -- move away from wall after placement
- for n = 1, buildLevels do
- buildLevel()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement