Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local platformRadius = 10
- local height = 50
- local gap = 4
- local blockCount = 0
- local steps = 0
- local requiredFuel = 0.5 * (height/3 * (platformRadius + 0.5) ^ 2 - (height-gap)*(platformRadius + 0.5-gap)^2)
- local chestSide = "front" -- set this to the side where the chest is located, e.g. "left", "right", "front", "back", or "up"
- function move()
- while not turtle.forward() do
- turtle.dig()
- end
- end
- function turnRight()
- turtle.turnRight()
- move()
- turtle.turnRight()
- end
- function turnLeft()
- turtle.turnLeft()
- move()
- turtle.turnLeft()
- end
- function buildLayer()
- for i = 1, platformRadius do
- turtle.placeDown()
- turnLeft()
- turtle.placeDown()
- turnRight()
- end
- end
- function buildPlatform()
- print("Checking Fuel...")
- if turtle.getFuelLevel() < requiredFuel then
- print("Error: Not enough fuel to complete the platform!")
- return false
- end
- print("Counting blocks needed...")
- local blocksNeeded = (height / gap) * platformRadius * 2
- print("Blocks needed: ", blocksNeeded)
- print("Fuel needed: ", requiredFuel)
- print("Building Platform...")
- while blockCount < height do
- buildLayer()
- blockCount = blockCount + (2 * platformRadius)
- platformRadius = platformRadius + gap
- steps = steps + 1
- if steps == 2 then -- adjust for the double layer in the first step
- platformRadius = platformRadius - 1
- end
- end
- print("Returning to chest...")
- turtle.turnLeft()
- turtle.turnLeft()
- while blockCount > 0 do
- turtle.digDown()
- move()
- blockCount = blockCount - 1
- if blockCount == 0 then
- for i = 1, 16 do -- loop through all inventory slots
- turtle.select(i)
- if turtle.getItemCount() > 0 then -- check if slot is not empty
- turtle.dropDown() -- drop item below
- end
- end
- turtle.refuel()
- platformRadius = 10 -- reset platform radius for new platform
- break
- end
- end
- print("Restocking...")
- turtle.select(1) -- select the first slot
- turtle.suck() -- suck items from chest into inventory
- turtle.suckUp() -- suck fuel from chest into inventory
- return true
- end
- print("Checking Fuel...")
- if turtle.getFuelLevel() < requiredFuel then
- print("Error: Not enough fuel to start the platform!")
- return
- end
- while true do
- if buildPlatform() == false then
- print("Pausing for 30 seconds to allow restocking...")
- sleep(30)
- end
- end
Add Comment
Please, Sign In to add comment