Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function forward(stp)
- if stp == 0 then
- do return end
- end
- for c=1,stp do
- while turtle.detect() do
- turtle.dig()
- sleep(1)
- end
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- end
- end
- function digroom(dimx, dimy)
- --We start from the middle, return to the middle, and resume our facing.
- --We can make halls with digroom, (1x2, 99x1 , etc)
- -- but please don't make 1x1 rooms. That's silly.
- --ALSO: No 0x0 or 0x3 etc rooms. That's not a room.
- if dimx == 1 then
- topleft = 0
- elseif dimx % 2 == 1 then
- topleft = (dimx - 1) / 2
- else
- topleft = dimx / 2
- if dimy == 1 then
- upmoves = 0
- elseif dimy % 2 == 1 then
- topup = (dimy -1) / 2
- else
- topup = dimy / 2
- end
- xmoves=dimx - 1
- forward(topup)
- turtle.turnLeft()
- forward(topleft)
- turtle.turnRight()
- --We are now in the "top-left" corner, and facing "north"
- for c=1,dimy do
- turtle.turnRight()
- forward(xmoves)
- turtle.turnLeft()
- turtle.turnLeft()
- forward(xmoves)
- if c < dimy then
- turtle.turnLeft()
- forward(1)
- turtle.turnRight()
- end
- turtle.turnRight()
- end
- -- We are now in the "bottom-left" corner, facing "north"
- -- Return to center.
- turtle.turnRight()
- forward(topleft)
- turtle.turnLeft()
- forward(topup)
- -- We are now in the middle, facing "north", and done.
- end
- function DigGrid(roomx, roomy, sizex, sizey)
- --We dig X rooms by Y rooms, of sizex by sizey. We start in the middle, facing "north"
- -- This assumes an odd number of rooms on both axis.
- if roomx % 2 == 0 then
- do return end
- elseif roomy %2 == 0 then
- do return end
- end
- midleft = sizex + 1
- midup = sizey + 1
- if roomy > 2 then
- roomup = (roomy - 1) / 2
- for ru=1,roomup do
- forward(midup)
- end
- end
- turtle.turnLeft()
- if roomx > 2 then
- roomleft = (roomx - 1) / 2
- for rl=1,roomleft do
- forward(midleft)
- end
- end
- turtle.turnRight()
- for ry=1,roomy do
- turtle.turnRight()
- for rx=1,roomx do
- digroom(sizex, sizey)
- if rx < roomx then
- forward(midleft)
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for rtx=1,roomx do
- if rtx < roomx then
- forward(midleft)
- end
- end
- if ry < roomy then
- turtle.turnLeft()
- turtle.turnLeft()
- forward(midup)
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- end
- DigGrid(5, 5, 5, 5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement