Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables
- turtle.select(1)
- height = 0
- // local tArgs = { ... }
- // local levelTotal = tonumber(tArgs[1])
- // levelTotal = levelTotal or 1
- -- Functions
- local function tMove(distance)
- for i=1,distance do
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- sleep(0.5)
- end
- end
- end
- local function tDescend(distance)
- for i=1,distance do
- while turtle.down() == false do
- turtle.digDown()
- turtle.attackDown()
- sleep(0.5)
- end
- end
- end
- local function tAscend(distance)
- for i=1,distance do
- while turtle.up() == false do
- turtle.digUp()
- turtle.attackUp()
- sleep(0.5)
- end
- end
- end
- local function turnaround()
- turtle.turnRight()
- turtle.turnRight()
- end
- local function checkInv(wanted)
- numReq = 0
- for i=1,15 do
- numReq = numReq + turtle.getItemCount(i)
- end
- if wanted > numReq then
- turtle.turnRight()
- tMove(5)
- turtle.turnRight()
- tMove(1)
- tDescend(height)
- for i=1,15 do
- turtle.select(i)
- turtle.suckDown(turtle.getItemSpace(i))
- end
- turtle.select(1)
- turnaround()
- tAscend(height)
- tMove(1)
- turtle.turnLeft()
- tMove(5)
- turtle.turnRight()
- end
- end
- local function tPlace()
- if turtle.getItemCount(1) == 0 then
- for i=2,15 do
- turtle.select(i)
- turtle.transferTo(1)
- end
- end
- turtle.select(1)
- while turtle.placeDown() == false do
- turtle.digDown()
- turtle.attackDown()
- end
- end
- -- -- delete section if above is working
- local function tPlaceBk()
- placedItem = 0
- for i=1,15 do
- if turtle.getItemCount(i) > 0 then
- if placedItem == 0 then
- turtle.select(i)
- turtle.placeDown()
- placedItem = 1
- end
- end
- end
- turtle.select(1)
- end
- local function tLineDraw(length)
- for i=1,length do
- tMove(1)
- tPlace()
- end
- end
- local function tOuterLoop()
- tLineDraw(2)
- turtle.turnLeft()
- tLineDraw(2)
- turtle.turnLeft()
- tLineDraw(1)
- end
- local function tLevelWall()
- checkInv(60)
- for wall=1,4 do
- tLineDraw(4)
- turtle.turnLeft()
- for c=1,3 do
- tLineDraw(2)
- turtle.turnRight()
- end
- tLineDraw(1)
- turnaround()
- tMove(1)
- tLineDraw(4)
- turtle.turnRight()
- end
- end
- local function tTorchPlace()
- turtle.select(16)
- while turtle.placeDown() == false do
- turtle.digDown()
- turtle.attackDown()
- end
- turtle.select(1)
- end
- local function tTorchCheck()
- if turtle.getItemCount(16) < 4 then
- tMove(5)
- turtle.turnLeft()
- tMove(1)
- tDescend(height)
- turtle.select(16)
- turtle.suckDown(turtle.getItemSpace(16))
- turtle.select(1)
- turnaround()
- tAscend(height)
- tMove(1)
- turtle.turnRight()
- tMove(5)
- turnaround()
- end
- end
- local function tFloorLoopNorm()
- tPlace()
- tLineDraw(10)
- turtle.turnLeft()
- tLineDraw(1)
- turtle.turnLeft()
- tLineDraw(10)
- turtle.turnRight()
- tMove(1)
- turtle.turnRight()
- end
- local function tLevelFloor()
- checkInv(141)
- tTorchCheck()
- turtle.turnRight()
- for i=1,5 do
- tFloorLoopNorm()
- end
- tPlace()
- tLineDraw(10)
- turnaround()
- tMove(4)
- turtle.turnRight()
- tOuterLoop()
- tMove(5)
- turtle.turnRight()
- tMove(4)
- tOuterLoop()
- tMove(11)
- tOuterLoop()
- tMove(7)
- turtle.turnLeft()
- tMove(6)
- tOuterLoop()
- tMove(1)
- turtle.turnLeft()
- tMove(6)
- turtle.turnRight()
- end
- local function tTorchLay()
- tTorchCheck()
- tMove(3)
- turtle.turnRight()
- tMove(3)
- tTorchPlace()
- tMove(4)
- tTorchPlace()
- turtle.turnLeft()
- tMove(4)
- tTorchPlace()
- turtle.turnLeft()
- tMove(4)
- tTorchPlace()
- tMove(3)
- turtle.turnLeft()
- tMove(7)
- turnaround()
- end
- -- Startup
- term.clear()
- term.setCursorPos(1,1)
- print("Please place blocks as follows:")
- print("Slot 1-15 - Building Material")
- print("Slot 16 - Torches")
- print("Chest Beneath - Building Material")
- print("Chest Beneath,Left - Torches")
- print()
- print("Enter number of floors:")
- levelTotal = read(input)
- tMove(1)
- turtle.turnLeft()
- tMove(5)
- turtle.turnRight()
- -- Main Loop
- for cycle=1,levelTotal do
- tTorchLay()
- tLevelWall()
- tAscend(1)
- height = height + 1
- tLevelWall()
- tAscend(1)
- height = height + 1
- tLevelWall()
- tAscend(1)
- height = height + 1
- tLevelFloor()
- tAscend(1)
- height = height + 1
- end
- tTorchLay()
- turtle.turnRight()
- tMove(5)
- turtle.turnRight()
- tMove(1)
- tDescend(height)
- turnaround()
Advertisement
Add Comment
Please, Sign In to add comment