Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Length?")
- local length = tonumber(read())
- local segments = length/8
- local brickItem = "MineFactoryReloaded:brick"
- local concreteItem = "Railcraft:cube"
- local railItem = "minecraft:rail"
- local lanternItem = "Railcraft:lantern.stone"
- function selectItem(name)
- local thisSlot = turtle.getItemDetail()
- if (thisSlot ~= nil) then
- if (thisSlot.name == name) then
- return
- end
- end
- for i=1,16 do
- local data = turtle.getItemDetail(i)
- if (data ~= nil) then
- if (data.name == name) then
- turtle.select(i)
- return
- end
- end
- end
- return false
- end
- function getItemCount(name)
- local sum = 0
- for i=1,16 do
- local data = turtle.getItemDetail(i)
- if (data ~= nil) then
- if (data.name == name) then
- sum = sum + data.count
- end
- end
- end
- return sum
- end
- function clearInventory()
- for i=1,16 do
- local slot = turtle.getItemDetail(i)
- if (slot ~= nil) then
- if (not(slot.name == brickItem or slot.name == concreteItem or slot.name == railItem or slot.name == lanternItem)) then
- turtle.select(i)
- if (slot.name == "minecraft:log") then
- turtle.refuel()
- else
- turtle.dropDown()
- end
- end
- end
- end
- end
- function checkItem(name,count)
- local c = getItemCount(name)
- while (c < count) do
- print("Add more ["..name.."] and press enter.")
- read()
- c = getItemCount(name)
- end
- end
- function checkFuel()
- local fuelLevel = turtle.getFuelLevel()
- local fuelEstimate = (length * 5) + (segments * 32)
- print("Fuel Level: "..fuelLevel.." Estimated needed: "..fuelEstimate)
- if (fuelLevel < fuelEstimate) then
- print("Not enough fuel. Refuel and try again.")
- os.sleep(2)
- shell.exit()
- end
- end
- function buildColumn()
- local depth = 0
- while(true) do
- local success, block = turtle.inspectDown()
- if (success and (block.name == "minecraft:grass" or
- block.name == "minecraft:dirt" or
- block.name == "minecraft:stone" or
- block.name == "minecraft:sand" or
- block.name == "minecraft:sandstone" or
- block.name == "minecraft:gravel" or
- block.name == "minecraft:bedrock")) then
- break
- else
- if (success) then
- turtle.digDown()
- end
- turtle.down()
- depth = depth + 1
- end
- end
- for i=1,depth do
- if (i == depth-1) then
- turtle.turnRight()
- selectItem(concreteItem)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- selectItem(concreteItem)
- turtle.place()
- turtle.turnRight()
- end
- turtle.up()
- selectItem(concreteItem)
- turtle.placeDown()
- end
- turtle.up()
- selectItem(lanternItem)
- turtle.placeDown()
- turtle.forward()
- turtle.down()
- end
- function buildRails()
- for i=1,8 do
- turtle.down()
- --Place bricks
- turtle.turnRight()
- if (turtle.detect()) then
- turtle.dig()
- end
- selectItem(brickItem)
- turtle.place()
- turtle.up()
- if (turtle.detect()) then
- turtle.dig()
- end
- selectItem(railItem)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.down()
- if (turtle.detect()) then
- turtle.dig()
- end
- selectItem(brickItem)
- turtle.place()
- turtle.up()
- if (turtle.detect()) then
- turtle.dig()
- end
- selectItem(railItem)
- turtle.place()
- turtle.turnRight()
- if (i ~= 8) then
- turtle.forward()
- end
- end
- end
- checkFuel()
- --Official Loop
- for i=1,segments do
- checkItem(brickItem, 16)
- checkItem(railItem, 16)
- checkItem(concreteItem, 64)
- checkItem(lanternItem, 1)
- print("Constructing segment "..i)
- buildRails()
- buildColumn()
- clearInventory()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement