Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- floor filler/ bridge maker? v1 by GooGoo @ pastebin, ThaWade @ ComputerCraft Forums
- --[[
- Known bugs: when turtle runs out of blocks in slot 1 it continues going but places no blocks.
- No refuel.
- TODO: Add a waitForBlocks bit of code. or make it check and move blocks to slot 1 while working?
- add refuel
- ]]
- --edited on 14, Nov, 2014. Reason: Rewrite of program.
- local tArgs = { ... }
- if #tArgs ~= 1 then
- print( "Usage: floor <amount>" )
- return
- end
- -- CONFIGS --
- length = tonumber(tArgs[1])
- local countOne = turtle.getItemCount(1)
- local countTwo = turtle.getItemCount(2)
- local countThree = turtle.getItemCount(3)
- local countFour = turtle.getItemCount(4)
- local maxCount = 64
- local minCount = 3
- local minAddCount = 1
- local getSpace = turtle.getItemSpace(1)
- t = turtle
- local blocksNeeded = length * 3
- local manAddBlocks = (blocksNeeded) - ((countOne + countTwo) + (countThree + countFour)) --for checkBlockInv()
- local moveBlocks = (blocksNeeded) - countOne
- local totalBlocks = ((countOne + countTwo) + (countThree + countFour))
- local yesOrNo
- -- CONFIGS END --
- function checkSlotOne()
- if countOne >= blocksNeeded then
- layFloor()
- elseif totalBlocks < blocksNeeded then
- fillSlot()
- elseif totalBlocks >= blocksNeeded then
- autoSortInv()
- else print("ERROR:@checkSlotOne() Func")
- end
- end
- function fillSlot()
- print("Please add atleast " ..manAddBlocks.." blocks to either slot 1 - 4.")
- sleep(2)
- repeat
- print("Have you added the blocks yet? Yes(y) or No(n)")
- yesOrNo = io.read()
- if yesOrNo == "y" then
- autoSortInv()
- elseif yesOrNo == "n" then
- exit()
- else print("Error:@fillSlot()! Type Y or N! If you did there's something wrong!")
- end
- until yesOrNo == "y" or yesOrNo == "n"
- end
- function checkBlockInv()
- if totalBlocks >= blocksNeeded then
- autoSortInv()
- end
- end
- local firstSlot,lastSlot = 1,4
- function autoSortInv()
- if countOne < blocksNeeded then
- t.select(1)
- t.transferTo(1)
- t.select(2)
- t.transferTo(1)
- t.select(3)
- t.transferTo(1)
- t.select(4)
- t.transferTo(1)
- layFloor()
- if countOne >= blocksNeeded then
- print("layFloor() would run now from autoSort")
- end
- end
- end
- function rightFace()
- t.turnRight()
- end
- function leftFace()
- t.turnLeft()
- end
- function aboutFace()
- rightFace()
- rightFace()
- end
- function leftBlock() -- digs and places a block to the left
- leftFace()
- t.dig()
- t.place()
- end
- function frontBlock() --digs block in front of turtle.
- t.select(1)
- t.dig()
- end
- function rightBlock() --digs and places a block to the right.
- aboutFace()
- t.dig()
- t.place()
- end
- function moveUp() --moves forward one block.
- leftFace()
- t.forward()
- end
- function rearBlock() -- places block behind turtle.
- aboutFace()
- t.place()
- aboutFace()
- end
- function layFloor()
- for x = 1, length do
- frontBlock()
- leftBlock()
- rightBlock()
- moveUp()
- rearBlock()
- end
- end
- function startPos()--Goes back to where you started the turtle.
- t.forward()
- end
- checkSlotOne()
- t.up()
- aboutFace()
- local home = length + 1
- for z=1, home do
- startPos()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement