Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Usage: place at Stone brick level, turtle facing against the wall (it will turn itself anyway)
- -- Supply with stone Blocks,
- -- Supply with dirt Blocks (cursed earth)
- -- it will build a whole floor row for a level (inside pre-built walls! https://pastebin.com/vBszs7pe )
- -- ItemSupply:
- -- rows, starting with 1
- stoneBlock = 1
- dirtBlock = 2
- spawnerHeight = 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, (row)*4 do
- -- exit if enough items
- if turtle.getItemCount(start-1) >= target then break end
- turtle.select(i)
- turtle.transferTo(start-1)
- end
- end
- function row2slot(row)
- return (row-1)*4+1
- end
- function buildLevel()
- -- build complete row
- -- check if turtle is on the correct level
- turtle.select(row2slot(stoneBlock))
- local ok, blockFront = turtle.inspect()
- local blockSlot = turtle.getItemDetail(row2slot(stoneBlock))
- if ok and blockSlot then
- if blockFront["name"] == blockSlot["name"] then
- turtle.up() -- at dirt level
- elseif turtle.inspect() and select(2, turtle.inspect())["name"] == turtle.getItemDetail(row2slot(dirtBlock))["name"] then
- -- dont move up, we are already on the correct level
- else
- error("The block in front of me is not DIRT! That doesn't seem right!")
- end
- else
- error("I must be placed against Brick or Dirt Blocks! Also make sure to add building supplies")
- end
- -- END OF CHECK
- -- place stone
- if stoneEnabled then
- moveSupplyRow(stoneBlock)
- turtle.select(row2slot(stoneBlock))
- turtle.placeDown()
- end
- if dirtEnabled then
- moveSupplyRow(dirtBlock)
- end
- while turtle.back() do
- turtle.select(row2slot(dirtBlock))
- turtle.place()
- turtle.select(row2slot(stoneBlock))
- turtle.placeDown()
- end
- turtle.up()
- turtle.select(row2slot(dirtBlock))
- turtle.placeDown()
- -- face against wall
- turtle.turnRight(); turtle.turnRight()
- for i = 1, spawnerHeight do
- if not turtle.up() then
- error("Cannot move upwards!")
- end
- end
- end
- buildLevels = 17
- stoneEnabled = true
- dirtEnabled = true
- print("How many levels to build? Default: ".. tostring(buildLevels))
- buildLevels = tonumber(io.read()) or buildLevels
- print("--> ".. tostring(buildLevels) .. " levels")
- -- turn Around, it must be placed against a wall
- if not turtle.detect() then
- turtle.turnRight(); turtle.turnRight()
- end
- for n = 1, buildLevels do
- buildLevel()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement