Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- variables
- local junkBlock = {"minecraft:stone","minecraft:sand","minecraft:dirt"}
- local isJunk = false
- local rawLenth = 1
- local rawNumber = 1
- -------------------------------------------
- -- Fonctions pour miner
- -------------------------------------------
- -- Fonction comparaison de block en face
- function compareBlockFront()
- if turtle.detect() == true then
- local isDetect, inspectedBlock = turtle.inspect()
- if isDetect == true then
- for i=1, table.getn(junkBlock) do
- if junkBlock[i] == inspectedBlock.name then
- isJunk = true
- return isJunk
- end
- end
- isJunk = false
- return isJunk
- end
- end
- end
- -- Fonction comparaison de block en haut
- function compareBlockUp()
- if turtle.detectUp() == true then
- local isDetect, inspectedBlock = turtle.inspectUp()
- if isDetect == true then
- for i=1, table.getn(junkBlock) do
- if junkBlock[i] == inspectedBlock.name then
- isJunk = true
- return isJunk
- end
- end
- isJunk = false
- return isJunk
- end
- end
- end
- -- Fonction comparaison de block en bas
- function compareBlockDown()
- if turtle.detectDown() == true then
- local isDetect, inspectedBlock = turtle.inspectDown()
- if isDetect == true then
- for i=1, table.getn(junkBlock) do
- if junkBlock[i] == inspectedBlock.name then
- isJunk = true
- return isJunk
- end
- end
- isJunk = false
- return isJunk
- end
- end
- end
- -- Fonction pour boucher les fuites en face
- function leakPluggingFront()
- if turtle.detect() == false then
- turtle.select(1)
- turtle.place()
- return true
- else
- return false
- end
- end
- -- Fonction pour boucher les fuites en haut
- function leakPluggingUp()
- if turtle.detectUp() == false then
- turtle.select(1)
- turtle.placeUp()
- return true
- else
- return false
- end
- end
- -- Fonction pour boucher les fuites en bas
- function leakPluggingDown()
- if turtle.detectDown() == false then
- turtle.select(1)
- turtle.placeDown()
- return true
- else
- return false
- end
- end
- -- Fonction pour miner en face
- function digFront()
- turtle.dig()
- turtle.select(2)
- turtle.place()
- end
- -- Fonction pour miner en haut
- function digUp()
- turtle.digUp()
- turtle.select(2)
- turtle.placeUp()
- end
- -- Fonction pour miner en bas
- function digDown()
- turtle.digDown()
- turtle.select(2)
- turtle.placeDown()
- end
- -- Changement de ligne de minage
- function newRaw()
- moveDown(1)
- turnLeft(1)
- moveForward(3)
- turnLeft(1)
- end
- -- Ligne de minage
- function digRaw(lenth)
- for i=1, lenth do
- moveForward(1)
- turnLeft(1)
- if compareBlockFront() == false then
- digFront()
- end
- turnRight(2)
- if compareBlockFront() == false then
- digFront()
- end
- turnLeft(1)
- if compareBlockDown() == false then
- digDown()
- end
- i=i+1
- end
- leakPluggingFront()
- moveUp(1)
- leakPluggingFront()
- turnRight(1)
- leakPluggingFront()
- turnLeft(2)
- leakPluggingFront()
- turnLeft(1)
- for i=1, lenth do
- moveForward(1)
- turnLeft(1)
- if compareBlockFront() == false then
- digFront()
- end
- turnRight(2)
- if compareBlockFront() == false then
- digFront()
- end
- turnLeft(1)
- if compareBlockUp() == false then
- digUp()
- end
- i=i+1
- end
- end
- -------------------------------------------
- -- Fonctions pour le deplacement
- -------------------------------------------
- -- Fonction pour se deplacer en avant
- function moveForward(lenth,floor,way,endBlock)
- floor = floor or false
- way = way or false
- endBlock = endBlock or false
- for i=1, lenth do
- if turtle.detect() == false then
- while turtle.forward() == false do
- turtle.attack()
- os.sleep(0.5)
- end
- else
- while turtle.forward() == false do
- turtle.dig()
- os.sleep(0.5)
- end
- end
- if floor == "b" then
- leakPluggingDown()
- elseif floor == "t" then
- leakPluggingUp()
- end
- if way == "l" then
- turnLeft(1)
- leakPluggingFront()
- turnRight(1)
- elseif way == "r" then
- turnRight(1)
- leakPluggingFront()
- turnLeft(1)
- end
- if i == lenth and endBlock == true then
- leakPluggingFront()
- end
- i=i+1
- end
- end
- -- Fonction pour se deplacer en haut
- function moveUp(lenth)
- for i=1, lenth do
- if turtle.detectUp() == false then
- while turtle.up() == false do
- turtle.attack()
- os.sleep(0.5)
- end
- else
- while turtle.up() == false do
- turtle.digUp()
- os.sleep(0.5)
- end
- end
- i=i+1
- end
- end
- -- Fonction pour se deplacer en bas
- function moveDown(lenth)
- for i=1, lenth do
- if turtle.detectDown() == false then
- while turtle.down() == false do
- turtle.attackDown()
- os.sleep(0.5)
- end
- else
- while turtle.forward() == false do
- turtle.dig()
- os.sleep(0.5)
- end
- end
- i=i+1
- end
- end
- -- Fonction pour tourner a droite
- function turnRight(nb)
- for i=1, nb do
- turtle.turnRight()
- i=i+1
- end
- end
- -- Fonction pour tourner a gauche
- function turnLeft(nb)
- for i=1, nb do
- turtle.turnLeft()
- i=i+1
- end
- end
- -------------------------------------------
- -- Inventaire
- -------------------------------------------
- -- placer un block en face
- function place(slot)
- slot = slot or turtle.getSelectedSlot()
- turtle.select(slot)
- turtle.place()
- end
- -- placer un block en haut
- function placeUp(slot)
- slot = slot or turtle.getSelectedSlot()
- turtle.select(slot)
- turtle.placeUp()
- end
- -- placer un block en bas
- function placeDown(slot)
- slot = slot or turtle.getSelectedSlot()
- turtle.select(slot)
- turtle.placeDown()
- end
- -- gestion des slots rΓ©servΓ©s
- -------------------------------------------
- -- Gestion du carburant
- -------------------------------------------
- -- Controle du niveau de carburant
- -- Recharger en carburant
- -------------------------------------------
- -- Mise en route
- -------------------------------------------
- -- Creation de la salle de depart
- --[[
- moveForward(2,"b","l",true)
- turnRight(1)
- moveForward(1,"b","l")
- turnRight(1)
- moveForward(2,"b","m",true)
- turnLeft(1)
- moveForward(1,"b","r")
- turnLeft(1)
- moveForward(2,"b","r",true)
- moveUp(1)
- turnLeft(2)
- moveForward(2,"t","l",true)
- turnRight(1)
- moveForward(1,"t","l")
- turnRight(1)
- moveForward(2,"t","m",true)
- turnLeft(1)
- moveForward(1,"t","r")
- turnLeft(1)
- moveForward(2,"t","r")
- turnLeft(2)
- moveDown(1)
- moveForward(1)
- turnRight(1)
- moveForward(1)
- turnRight(1)
- place(5)
- turnLeft(1)
- moveForward(1)
- turnRight(1)
- place(5)
- moveUp(1)
- place(5)
- turnRight(1)
- moveForward(1)
- turnLeft(1)
- place(5)
- turnRight(1)
- moveForward(1)
- turtle.dig()
- place(1)
- moveDown(1)
- turnLeft(2)
- moveForward(1)
- turnLeft(1)
- moveForward(1)
- print('Ready to start ? press "enter"')
- ok = read()
- --]]
- -- saisie des dimentions de minage
- print("Lenth of eatch raw ?")
- rawLenth = read()
- print("Number of raw ?")
- rawNumber = read()
- for i=1, rawNumber do
- digRaw(rawLenth)
- newRaw()
- end
- turnLeft(1)
- moveUp(1)
- moveForward(rawNumber*3)
- turnLeft(1)
- moveDown(1)
- moveForward(1)
- -- vider l'inventaire
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement