Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function moveSafely()
- while(turtle.detect()) do
- turtle.dig()
- end
- turtle.forward()
- end
- function reverse()
- turtle.turnRight()
- turtle.turnRight()
- end
- function moveLeft(blocks)
- turtle.turnLeft()
- for i=1,blocks do
- turtle.forward()
- end
- turtle.turnRight()
- end
- function moveRight(blocks)
- turtle.turnRight()
- for i=1,blocks do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- function moveForward(blocks)
- for i=1,blocks do
- turtle.forward()
- end
- end
- function moveBackwards(blocks)
- reverse()
- moveForward(blocks)
- reverse()
- end
- function prepareLine(amount)
- for i=1,amount do
- turtle.moveSafely()
- end
- end
- function prepare(x, y)
- local s = 1
- for i=1,4 do
- prepareLine(SizePairSwitch(1))
- s = s * -1
- turtle.turnLeft()
- end
- end
- function SizePairSwitch(num, x, y)
- if (num == 1) then
- return x
- else
- return y
- end
- end
- function placeBelowLine(amount)
- for i=1,amount-1 do
- turtle.placeDown()
- moveSafely()
- end
- turtle.placeDown()
- end
- function place(x, y)
- local s = 1
- for i=1,4 do
- placeBelowLine(SizePairSwitch(s, x, y))
- s = s * -1
- turtle.turnRight()
- end
- end
- function turnNum(num)
- if (num == 1) then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- function digAllLine(amount)
- for i=1,amount-1 do
- turtle.dig()
- moveSafely()
- end
- end
- function backToStart(x, y)
- if(x % 2 == 0) then
- moveRight(x-1)
- reverse()
- else
- moveLeft(x-1)
- moveBackwards(y-1)
- end
- end
- function digFloor(x, y)
- local s = 1
- for i=1,x-1 do
- digAllLine(y)
- turnNum(s)
- s = s * -1
- end
- digAllLine(y)
- backToStart(x, y)
- end
- function placeFloor(x, y)
- local s = 1
- for i=1,x-1 do
- placeBelowLine(y)
- turnNum(s)
- s = s * -1
- end
- placeBelowLine(y)
- backToStart(x, y)
- end
- function main(x, y, h)
- --turtle.digDown()
- --turtle.down()
- --digFloor(x, y)
- --turtle.up()
- --placeFloor(x, y)
- --for i=1,h-2 do
- for i=1,h do
- turtle.up()
- place(x, y)
- end
- turtle.up()
- placeFloor(x, y)
- end
- print("length(right):")
- local x = tonumber(read())
- print("width(forward):")
- local y = tonumber(read())
- print("height:")
- local h = tonumber(read())
- main(x, y, h)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement