--slot 1 block

--slot 2 shield

--slot 3 frame

--slot 4 light

--slot 5 slabs

-- you can change the layout here each number is the slot it uses, 0 for no block placed.

local layers = { { { 1 , 1 , 1 } , { 2 , 4 , 3 } , { 2 , 2 , 2 } } ,

{ { 2 , 2 , 2 } , { 2 , 2 , 2 } , { 2 , 2 , 2 } } ,

{ { 2 , 2 , 2 } , { 2 , 2 , 2 } , { 2 , 2 , 2 } } ,

{ { 5 , 5 , 5 } , { 5 , 5 , 5 } , { 5 , 5 , 5 } } }

local back = false -- for when the turle is going to the next line wether to turn left or right

local lineSize -- used so the turtle can move to the beginning of the next cycle

local numTypesOfItems = 5 -- number of item types the structure has in it

local debugInfo = true -- mainly for the thing directly below here.

-- prints contents of each layer

if debugInfo then

for i = 1 , # layers do

print ( "Layer " .. i .. ":" )

local layer = layers [ i ]

for j = 1 , # layer do

local line = layer [ j ]

local outString = ""

for k = 1 , # line do

outString = outString .. line [ k ] .. ""

end

print ( outString )

end

sleep ( 5 )

end

end

-- positions the turtle for placing the next line in a layer

function nextLine ( )

if back then

turtle . turnRight ( )

turtle . forward ( )

turtle . turnRight ( )

back = false

else

turtle . turnLeft ( )

turtle . forward ( )

turtle . turnLeft ( )

back = true

end

end

-- TODO make is so this works with a odd number of layers not just even

function reposition ( a , b )

turtle . turnRight ( )

for i = 1 , ( a - 1 ) do

turtle . forward ( )

end

turtle . turnRight ( )

for i = 1 , ( b - 1 ) do

turtle . forward ( )

end

turtle . turnRight ( )

turtle . turnRight ( )

turtle . up ( )

end

-- refills the items used from the extra slots in the turtle's inventory

function check ( slot )

turtle . select ( slot )

for i = ( numTypesOfItems + 1 ) , 16 do

turtle . select ( i )

if turtle . compareTo ( slot ) then

turtle . transferTo ( slot )

return

end

end

turtle . select ( slot )

end

-- iriterates through the layer it's given and places the appropriate block from the slot

function placeLayer ( layer )

for x = 1 , # layer do

local line = layer [ x ]

lineSize = # line

for y = 1 , # line do

local slot = line [ y ]

if slot ~= 0 then

turtle . select ( line [ y ] )

turtle . placeDown ( )

end

if y ~= # line then

turtle . forward ( )

end

end

if x ~= # layer then

nextLine ( )

end

end

back = false

reposition ( # layer , lineSize )

end

local tArgs = { ... }

local cycles = 1

-- checks if there's a commandline arg

if # tArgs >= 1 then

cycles = tArgs [ 1 ]

end

-- error checks the arg

if tonumber ( cycles ) <= 0 then

cycles = 1

end

-- main cycle

for j = 1 , cycles do

print ( "Cycle " .. j .. " of " .. cycles )

turtle . forward ( )

turtle . up ( )

for i = 1 , # layers do

placeLayer ( layers [ i ] )

end

for i = 1 , lineSize do

turtle . forward ( )

end

for i = 1 , ( # layers + 1 ) do

turtle . down ( )

end

for i = 1 , numTypesOfItems do

check ( i )

end