Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lenth = 4 -- lenth
- local width = 5 -- width
- local height = 2 -- height of walls
- local floors = 1 -- how many floors+walls to build
- local walls = true -- do you need walls or just floor
- local ceiling = true -- do you need to build roof
- -------------------------------------------------------
- local t = turtle
- local currentSlot = 1
- t.placeDownOld = t.placeDown
- lenth = lenth - 2
- width = width - 2
- function t.placeDown()
- CheckSlot()
- t.placeDownOld()
- end
- function CalcBlocks()
- local blocks = 0
- local w = width+2
- local l = lenth+2
- blocks = blocks + w*l*floors
- blocks = blocks + (walls and (w+l-2)*2*floors*height or 0)
- blocks = blocks + (ceiling and w*l or 0)
- return blocks
- end
- function CheckSlot()
- if t.getItemCount(currentSlot) == 0 then
- if currentSlot == 16 then
- print("WAITING FOR BLOCKS")
- currentSlot = 1
- t.select(1)
- while t.getItemCount() == 0 do
- sleep(1)
- end
- else
- currentSlot = currentSlot + 1
- t.select(currentSlot)
- CheckSlot()
- end
- end
- end
- function BuildFloor()
- local side = 0
- t.up()
- if not(walls) then
- width = width - 2
- lenth = lenth - 2
- end
- for i = 1, width+2 do
- for i = 1, lenth+1 do
- t.placeDown()
- t.forward()
- end
- t.placeDown()
- if i ~= width+2 then
- if side == 0 then
- t.turnRight()
- t.forward()
- t.turnRight()
- elseif side == 1 then
- t.turnLeft()
- t.forward()
- t.turnLeft()
- end
- side = 1 - side
- end
- end
- end
- function BuildWalls()
- if width%2 == 0 then
- t.turnLeft()
- t.turnLeft()
- for i = 1, lenth+1 do
- t.forward()
- end
- end
- t.turnLeft()
- t.forward()
- for i = 1, height do
- t.up()
- for i = 1, 2 do
- for i = 1, width do
- t.placeDown()
- t.forward()
- end
- t.placeDown()
- t.turnLeft()
- t.forward()
- for i = 1, lenth do
- t.placeDown()
- t.forward()
- end
- t.placeDown()
- t.turnLeft()
- t.forward()
- end
- end
- for i = 1, width do
- t.forward()
- end
- t.turnLeft()
- for i = 1, lenth+1 do
- t.forward()
- end
- t.turnLeft()
- t.turnLeft()
- end
- if t ~= nil then
- term.clear()
- term.setCursorPos(1, 1)
- print("PICKAR'S BUILDER v1.0")
- print("YOU WILL NEED "..CalcBlocks().." BLOCKS")
- print("ITS ".. (CalcBlocks()-CalcBlocks()%64)/64 .." STACK AND ".. CalcBlocks()%64 .." BLOCKS")
- if walls then
- if floors == 1 then
- BuildFloor()
- BuildWalls()
- else
- for i = 1, floors do
- BuildFloor()
- BuildWalls()
- end
- end
- if ceiling then
- BuildFloor()
- BuildFloor()
- end
- else
- BuildFloor()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement