Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("futur miner main prog")
- ramassage = false
- function mine(DistInput)
- DistParc = 0
- turtle.digDown()
- turtle.digUp()
- while DistParc ~= DistInput do
- while turtle.detect() do
- turtle.dig()
- end
- if turtle.forward() then
- DistParc = DistParc + 1
- turtle.digDown()
- turtle.digUp()
- else
- turtle.attack()
- end
- if DistParc/20 == math.floor(DistParc/20) then
- if turtle.getFuelLevel() < 256 then
- print("need fuel")
- refuel()
- end
- end
- end
- end
- function refuel()
- for slot = 1, 16 do
- turtle.select(slot)
- if turtle.refuel(8) then
- turtle.select(1)
- return true
- end
- end
- turtle.select(1)
- return false
- end
- function position()
- id, msg, protocol = rednet.receive("position")
- ligne = msg[1]
- colonne = msg[2]
- if colonne == 0 and ligne == 0 then
- success, data = turtle.inspect()
- print(data.name)
- if data.name == "ComputerCraft:CC-Turtle" or data.name == "ComputerCraft:CC-TurtleExpanded" then
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- if colonne ~= 0 then
- turtle.turnLeft()
- for i=1, colonne do
- success, data = turtle.inspect()
- while data.name == "ComputerCraft:CC-Turtle" or data.name == "ComputerCraft:CC-TurtleExpanded" do
- sleep(2)
- success, data = turtle.inspect()
- end
- while not turtle.forward() do
- turtle.dig()
- end
- end
- turtle.turnRight()
- end
- if ligne ~= 0 then
- for i = 1, 3*ligne do
- success, data = turtle.inspectUp()
- while data.name == "ComputerCraft:CC-Turtle" or data.name == "ComputerCraft:CC-TurtleExpanded" do
- sleep(2)
- success, data = turtle.inspectUp()
- end
- while not turtle.up() do
- turtle.digUp()
- end
- end
- end
- while not turtle.forward() do
- turtle.dig()
- end
- end
- function loot()
- if ligne ~= 0 then
- for i=1, ligne*2 do
- while not turtle.down() do
- sleep(0.2)
- local success, data = turtle.inspectDown()
- if data.name ~= "ComputerCraft:CC-Turtle" and data.name ~= "ComputerCraft:CC-TurtleExpanded" then
- turtle.digDown()
- end
- print("je suis québlo gros")
- end
- end
- end
- if ligne == 0 then
- if colonne == 0 then
- turtle.turnRight()
- end
- turtle.turnRight()
- while msg == "l" do
- for i=1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- if protocol == "r" then
- recup()
- end
- id, msg, protocol = rednet.receive(10)
- end
- sleep(0.1)
- else
- while msg == "l" do
- for i=1, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- if protocol == "r" then
- recup()
- end
- id, msg, protocol = rednet.receive(10)
- end
- end
- if ligne ~= 0 then
- for i=1, ligne*2 do
- while not turtle.up() do
- sleep(0.2)
- local success, data = turtle.inspectUp()
- if data.name ~= "ComputerCraft:CC-Turtle" and data.name ~= "ComputerCraft:CC-TurtleExpanded" then
- turtle.digUp()
- end
- print("je suis québlo gros1")
- end
- end
- end
- if ligne == 0 then
- if colonne == 0 then
- turtle.turnLeft()
- end
- turtle.turnLeft()
- end
- end
- function recup()
- if ligne == 0 then -- bas
- sleep(5)
- while true do
- if not ramassage then
- turtle.turnRight()
- if colonne ~= 0 then
- turtle.turnRight()
- end
- ramassage = true
- end
- turtle.suckUp()
- if redstone.getInput("top") then
- turtle.digUp()
- end
- local success, data = turtle.inspectUp()
- if data.name ~= "ComputerCraft:CC-Turtle" and data.name ~= "ComputerCraft:CC-TurtleExpanded" then
- while true do
- local success, data = turtle.inspect()
- if data.name ~= "ComputerCraft:CC-Turtle" and data.name ~= "ComputerCraft:CC-TurtleExpanded" then
- if vide() then
- if colonne == 0 then
- redstone.setOutput("bottom", true)
- else
- redstone.setOutput("back", true)
- end
- end
- else
- turtle.suck()
- if redstone.getInput("front") and vide() then
- turtle.dig()
- end
- end
- end
- end
- end
- else -- haut
- sleep(5)
- while true do
- local success, data = turtle.inspectUp()
- if data.name ~= "ComputerCraft:CC-Turtle" and data.name ~= "ComputerCraft:CC-TurtleExpanded" then
- redstone.setOutput("bottom", true)
- else
- if redstone.getInput("top") then
- turtle.digUp()
- else
- turtle.suckUp()
- end
- end
- end
- end
- end
- function vide()
- for i=1, 16 do
- turtle.select(i)
- if turtle.getItemCount() ~= 0 then
- return false
- end
- end
- return true
- end
- rednet.open("right")
- position()
- while true do
- id, msg, protocol = rednet.receive()
- if protocol == "m" then
- print(msg)
- mine(msg)
- end
- if msg == "l" then
- print("Loot")
- loot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement