Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- BaseBuilding Turtle
- -- Digs out rooms 16x16x4, with a staircase spiraling along the edges
- -- Should always be started at the top-left corner of the area to dig...
- -- No idea how I'm gonna get the stars to work, but the main part should be really easy
- local startZ = nil
- local startX = nil
- local startY = nil
- local cobbleSlot = 1
- local firstFuelSlot = 12
- local numFuelSlots = 4
- function refuel()
- -- Fix the inventory. Let's reserve the last 4 slots all for coal
- -- So first, check those 4 slots and if they have noncoal in them, drop them
- -- Then check all other slots, and if they have coal, try to put them in those 4 slots
- -- Also, discard all cobblestone except slot 1, stack it there
- -- There are 16 slots, we want 12-16
- for i=firstFuelSlot,firstFuelSlot+numFuelSlots do
- local data = turtle.getItemDetail(i)
- if data ~= nil then
- print("Found in slot " .. i .. ": ", data.name)
- if data.name ~= "minecraft:coal" then
- turtle.select(i)
- turtle.drop()
- print("Dropping slot " .. i .. " because it's in the coal slot")
- end
- end
- end
- -- Now the rest
- for i=1,firstFuelSlot-1 do
- local data = turtle.getItemDetail(i)
- if data ~= nil then
- print("Found in slot " .. i .. ": ", data.name)
- if data.name == "minecraft:coal" then
- -- Just try them all
- turtle.select(i)
- print("Transferring coal to all fuel slots")
- for j=firstFuelSlot,firstFuelSlot+numFuelSlots do
- turtle.transferTo(j)
- end
- elseif data.name == "minecraft:cobblestone" then
- -- Try to transfer it to cobbleSlot
- turtle.select(i)
- turtle.transferTo(cobbleSlot)
- -- Drop any remainders
- turtle.drop()
- end
- end
- end
- -- And lastly, iterate the fuel slots and refuel
- for i=firstFuelSlot,firstFuelSlot+numFuelSlots do
- turtle.select(i)
- turtle.refuel()
- end
- end
- turtle.select(firstFuelSlot)
- turtle.refuel()
- turtle.select(cobbleSlot)
- while(true) do
- for z=1,4 do
- if startZ then z = startZ startZ = nil end
- for x=1,16 do -- Same, always already in the first one
- if startX then x = startX startX = nil end
- for y=1,16 do -- We're always inside the first one
- if startY then y = startY startY = nil end
- turtle.dig()
- turtle.suck()
- turtle.forward()
- if not turtle.detectDown() and z == 4 then turtle.placeDown() end -- Make sure the floors are filled in
- if not turtle.detectUp() and z == 1 then turtle.placeUp() end -- And the ceilings, which are 1 below the floors
- end
- -- Reached the end on this side, turn (right/left)...
- if x < 16 then
- if x%2 == 1 then turtle.turnRight() else turtle.turnLeft() end
- turtle.dig()
- turtle.forward()
- if x%2 == 1 then turtle.turnRight() else turtle.turnLeft() end
- end
- -- Ready to iterate again
- end
- -- We've cleared out a 16x16 area on this level.
- -- And we are currently in the last block we broke...
- -- So the staircase is to our left. But, for everything except z==1
- -- We need to do a 180 and go to the opening
- if z > 1 then
- turtle.turnLeft()
- turtle.turnLeft()
- for i=2,z do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.forward() -- There should already be nothing there
- turtle.turnLeft()
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- -- Both situations leave us facing to where we need to dig and go down
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- turtle.down()
- if z < 4 then
- -- Figure out how to get back to our starting point.
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- for temp=1,z do -- We will be [z] blocks from the edge on this side
- turtle.dig()
- turtle.forward()
- end
- turtle.turnRight()
- -- And a full 16 blocks from the next edge inclusive, but, we're inclusive on two points
- -- So up to 15
- for temp=1,15 do
- turtle.dig()
- turtle.forward()
- end
- turtle.turnRight() -- And it's ready to iterate again
- end
- end
- -- We have successfully dug 16x16x4
- -- And are on our stairwell area, on the 5th block into the stairwell
- -- This is a good time to ditch items, since we don't pick things up on the stairwell and they won't fall
- refuel()
- -- Continue the stairwell down to 8
- for temp=5,8 do -- This works for both halves
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- turtle.down()
- end
- -- Get back to the starting position
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- -- We are on block 8 and want to be on block 1
- for temp=8,1,-1 do
- turtle.dig()
- turtle.forward()
- end
- turtle.turnRight()
- -- And we're ready to iterate again
- end
Add Comment
Please, Sign In to add comment