Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- build a pathway
- --rednet.open("left")
- function waitForRednet()
- while c == nil do
- a,b = rednet.receive()
- if b == "beginpath" then
- c="begun"
- print(c)
- return
- end
- end
- end
- blockToBuildWith = "minecraft:netherrack"
- magmaBlock = "minecraft:magma_block"
- fuelBuffer = 100
- refuelSlot = 11
- forwardCount = 0
- function waitUntilNextMoment()
- -- while not (os.time()*1000 %70 == 0) do
- -- sleep(0.05)
- -- end
- end
- function ifLava()
- function goBack(b)
- b = b or "nothing"
- if b.name == "minecraft:lava" then
- turtle.place()
- turtle.placeUp()
- turtle.placeDown()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1, 15 do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- error("Ran into lava")
- end
- end
- local a,b = turtle.inspectUp()
- goBack(b)
- local a,b turtle.inspect()
- goBack(b)
- end
- function searchSlotsFor(blockId)
- for slot = 1,16 do
- turtle.select(slot)
- local i = turtle.getItemDetail() or "nothing"
- if i ~= "nothing" then
- if i.name == blockId then
- return slot
- else
- end
- end
- end
- return "nothing found"
- end
- function findBlock(blockId)
- local i = turtle.getItemDetail() or "nothing"
- if i ~= "nothing" and i.name == blockId then
- return true
- else
- slot = searchSlotsFor(blockToBuildWith)
- if slot ~= "nothing found" then
- return true
- else
- print("Nothing found to build with")
- while searchSlotsFor(blockToBuildWith) == "nothing found" do
- sleep(2)
- write(".")
- end
- end
- end
- end
- function build()
- if findBlock(blockToBuildWith) == true then
- turtle.placeDown()
- end
- end
- function dig()
- while turtle.detect() == true do
- turtle.dig()
- end
- end
- function digUp()
- while turtle.detectUp() == true do
- turtle.digUp()
- end
- end
- function digAll()
- dig()
- digUp()
- end
- function forward()
- turtle.forward()
- end
- function refuel()
- if turtle.getFuelLevel() <= fuelBuffer then
- turtle.select(refuelSlot)
- fuelInSlot = turtle.refuel(0)
- if fuelInSlot then
- turtle.refuel(1)
- else
- print("please refuel to slot "..refuelSlot)
- while turtle.refuel(0) == false do
- sleep(2)
- write(".")
- end
- turtle.refuel(1)
- end
- end
- end
- rednetSide = "left"
- function checkRedent()
- rednet.open(rednetSide)
- parallel.waitForAny(
- function()
- sleep(0.2)
- end,
- function()
- a,b = rednet.receive()
- a=nil
- end
- )
- rednet.close()
- print(a)
- print(b)
- if b ~= nil then
- if b == "endpath" then
- print("stopped by rednet")
- error()
- end
- else
- return false
- end
- end
- function removeMagma()
- local a,b = turtle.inspectDown()
- if b~= nil then
- local name = b.name or "nothing"
- if name == magmaBlock then
- turtle.digDown()
- end
- end
- end
- --waitForRednet()
- while true do
- refuel()
- removeMagma()
- build()
- digAll()
- forward()
- ifLava()
- --waitUntilNextMoment()
- --checkRedent()
- end
Add Comment
Please, Sign In to add comment