Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function selectNextSlot()
- for i=1,16 do
- local slot = (turtle.getSelectedSlot() % 16) + 1
- turtle.select(slot)
- if turtle.getItemCount() > 0 then return true end
- end
- return false
- end
- function placeWallBlock()
- while not turtle.placeDown() do
- if turtle.getItemCount() == 0 and not selectNextSlot() then
- error("Out of blocks while placing down for walls")
- end
- sleep(0.1)
- end
- end
- function forwardSafe()
- while not turtle.forward() do
- turtle.dig()
- sleep(0.1)
- end
- end
- function upSafe()
- while not turtle.up() do
- turtle.digUp()
- sleep(0.1)
- end
- end
- function downSafe()
- while not turtle.down() do
- turtle.digDown()
- sleep(0.1)
- end
- end
- -- === WALL BUILD TEST (FIXED) ===
- function testWalls()
- local length, width, height = 3, 3, 3
- local wallHeight = height - 2
- if wallHeight < 1 then return end
- print("Going up to layer 2...")
- upSafe()
- for h = 1, wallHeight do
- print("Building wall layer "..h)
- for side = 1, 4 do
- local distance = (side % 2 == 1) and length or width
- for i = 1, distance do
- placeWallBlock()
- if i < distance then forwardSafe() end
- end
- turtle.turnRight()
- end
- if h < wallHeight then upSafe() end
- end
- print("Returning to ground...")
- for i = 1, wallHeight do downSafe() end
- end
- -- Run test
- testWalls()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement