Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function select(info)
- if info == "ladder" then
- turtle.select(1)
- elseif info == "torch" then
- turtle.select(2)
- elseif info == "cobblestone" then
- turtle.select(4)
- end
- end
- function place(direction)
- if direction == "front" then
- turtle.place()
- elseif direction == "around" then
- turn("around")
- turtle.place()
- elseif direction == "left" then
- turn("left")
- turtle.place()
- elseif direction == "right" then
- turn("right")
- turtle.place()
- elseif direction == "up" then
- turtle.placeUp()
- elseif direction == "down" then
- turtle.placeDown()
- end
- reStock("cobblestone")
- end
- function reStock(info)
- note = ""
- if info == "torch" then
- select("torch")
- if turtle.compareTo(3) then
- note = turtle.getItemSpace(turtle.getSelectedSlot())
- turtle.select(3)
- turtle.transferTo(2,64-note)
- end
- elseif info == "cobblestone" then
- index = 4
- fill = false
- while not fill or index <= 16 do
- if turtle.compare(index) then
- note = turtle.getItemCount(turtle.getSelectedSlot())
- turtle.select(index)
- turtle.transferTo(4,64-note)
- select("cobblestone")
- end
- if turtle.getItemSpace(turtle.getSelectedSlot()) == 64 then
- fill = true
- end
- i = i + 1
- end
- end
- end
- function digging(direction)
- if direction == "up" then
- turtle.digUp()
- elseif direction == "down" then
- turtle.digDown()
- elseif direction == "left" then
- turn("left")
- turtle.dig()
- elseif direction == "around" then
- turn("around")
- turtle.dig()
- elseif direction == "right" then
- turn("right")
- turtle.dig()
- elseif direction == "front" then
- turtle.dig()
- end
- end
- function move(direction)
- if direction == "down" then
- turtle.down()
- elseif direction == "up" then
- turtle.up()
- elseif direction == "forward" then
- turtle.forward()
- elseif direction == "around" then
- turn("around")
- turtle.forward()
- elseif direction == "right" then
- turn("right")
- turtle.forward()
- elseif direction == "left" then
- turn("left")
- turtle.forward()
- end
- refueling()
- end
- function turn(direction)
- if direction == "right" then
- turtle.turnRight()
- elseif direction == "left" then
- turtle.turnLeft()
- elseif direction == "around" then
- for i = 1,2 do
- turtle.turnRight()
- end
- end
- end
- function torch()
- select("torch")
- turn("around")
- turtle.place()
- reStock("torch")
- turn("around")
- end
- function ladder()
- select("ladder")
- turtle.placeUp()
- reStock("ladder")
- end
- function refueling()
- if turtle.getFuelLevel() < 100 then
- for i = 1,16 do
- turtle.select(i)
- if turtle.refuel(0) then
- turtle.refuel(1)
- end
- end
- end
- end
- function checkSides()
- for i = 0,3 do
- turtle.turnRight()
- if i < 3 then
- select("cobblestone")
- place("front")
- end
- end
- end
- function ladderProgram(currentLayer,desiredLayer)
- print("Beginning the ladderProgram")
- index = currentLayer
- digging("front")
- while index > desiredLayer do
- digging("down")
- checkSides()
- move("down")
- ladder()
- end
- end
- function branch(length)
- t = 8
- for i = 1,2 do
- for i = 0,length do
- while turtle.detect() do
- digging("front")
- os.sleep(0.5)
- end
- if not turtle.detectDown() then
- select("cobblestone")
- place("down")
- end
- move("front")
- t = t - 1
- if t == 0 then
- torch()
- t = 8
- end
- end
- turn("around")
- for i = 0,length do
- move("front")
- end
- end
- turn("right")
- end
- function nextBranch(length)
- for i = 1,3 do
- if i == 1 then
- torch()
- end
- for j = 1,3 do
- digging("front")
- move("forward")
- digging("up")
- if not turtle.detectDown() then
- select("cobblestone")
- place("down")
- restock("cobblestone")
- end
- end
- turn("left")
- branch(length)
- end
- end
- function mining(length)
- print("Beginning the miningProgram")
- while true do
- nextBranch(length)
- end
- end
- function main()
- print("write one of the things below for what action i should do")
- print("ladder")
- print("mining")
- local input = read()
- print("you entered: ", input)
- if input == "ladder" then
- print("what layer am I on?")
- local input2 = tonumber(read())
- print ("where should I go down to?")
- local input3 = tonumber(read())
- print("gimme: ", input2 - input3 - 1, " of Ladders")
- local input4 = read()
- print ("going down to layer: ", input3, "from: ", input2)
- ladderProgram(input2,input3)
- elseif input == "mining" then
- print("what length should the branch be?")
- local length = read()
- print(" naow gimme torches on position 2 and 3!!")
- print("some fuel like charcoal/coal or lava bucket would be nice")
- print("waiting for the - go - command")
- local input = read()
- if input == "go" then
- mining(length)
- end
- end
- end
- refueling()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement