Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local targs = {...}
- if #targs ~= 2 then
- print("floor <length> <width>")
- error()
- end
- local length = tonumber(targs[1])
- local height = tonumber(targs[2])
- local curBlockSelection = 2
- -- Functions used in Main code
- function confirmBlock()
- if turtle.getItemCount(curSelection) <= 1 then
- for i = 1, 16 do
- if turtle.compareTo(i) and not (i == curBlockSelection) then
- turtle.select(i)
- turtle.transferTo(curBlockSelection)
- turtle.select(curBlockSelection)
- end
- end
- if turtle.getItemCount(curSelection) <= 1 then
- print("No more wall block in inventory, we fucked")
- error()
- end
- end
- end
- function moveUp()
- if not turtle.up() then
- turtle.digUp()
- turtle.up()
- end
- end
- function placeUp()
- confirmBlock()
- if not turtle.placeUp() then
- turtle.digUp()
- turtle.placeUp()
- end
- end
- function moveDown()
- if not turtle.down() then
- turtle.digDown()
- turtle.down()
- end
- end
- function placeDown()
- confirmBlock()
- if not turtle.placeDown() then
- turtle.digDown()
- turtle.placeDown()
- end
- end
- function moveForward()
- confirmBlock()
- if not turtle.forward() then
- turtle.dig()
- turtle.forward()
- end
- end
- --Initialization (refuel and get initial position)
- turtle.refuel()
- turtle.select(curSelection)
- for i = 1, height - 2 do
- moveUp()
- end
- -- Starts on opposite side on odd cases so it will reposition back correctly at the end
- if (height % 2) == 1 then
- for i = 1, length do
- moveForward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- --Main Wall-Making Code
- for j = 1, height do
- for i = 1, length do
- if (turtle.getFuelLevel() <= 1) then
- turtle.refuel()
- end
- placeUp()
- moveForward()
- end
- print("Finished ", j ," out of ", height, " rows")
- moveDown()
- turtle.turnLeft()
- turtle.turnLeft()
- moveForward()
- end
- turtle.back()
- for i = 1, 2 do
- moveUp()
- turtle.turnLeft()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement