Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local firstSlotBlackList = 1 --Slots for compare dirt/stone/...
- local lastSlotBlackList = 4
- local firstSlot = 5 --Slots for store ore
- local lastSlot = 12
- local cobleChestSlot = 13 -- Slots for send/recive items
- local useSlot = 14
- local coalChestSlot = 15
- local enderChestSlot = 16
- function emptyIfFull() --check if the turtle is full and empty it
- if (turtle.getItemCount(lastSlot-1) > 0) then
- print("Vidange des items...")
- turtle.select(enderChestSlot)
- turtle.placeUp()
- sleep(0.15)
- for slot=firstSlot,lastSlot do
- turtle.select(slot)
- while turtle.getItemCount(slot) > 0 do
- turtle.dropUp(turtle.getItemCount(slot))
- if turtle.getItemCount(slot) > 0 then
- sleep(5)
- end
- end
- end
- print("Fin")
- turtle.select(enderChestSlot)
- turtle.digUp()
- end
- end
- function refuelIfEmpty() --fill the fuel of the turtle
- if turtle.getFuelLevel()<500 then
- print("Remplissage de Coal...")
- turtle.select(coalChestSlot)
- turtle.placeUp()
- turtle.select(useSlot)
- turtle.suckUp(32)
- turtle.refuel(32)
- print("Fin")
- turtle.select(coalChestSlot)
- turtle.digUp()
- end
- end
- function checkDig() --check if is not blacklisted and dig it if it's true
- local dig = true
- for slot=firstSlotBlackList,lastSlotBlackList do
- turtle.select(slot)
- if turtle.compare() then
- dig = false
- end
- end
- if dig then
- turtle.dig()
- end
- end
- function well() -- dig the well and ores
- local depth = 1
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- while turtle.down() do
- for i=0,3 do
- turtle.turnRight()
- checkDig()
- end
- emptyIfFull()
- depth = depth+1
- turtle.digDown()
- end
- return depth
- end
- function up(depth)
- for i=1,depth do
- turtle.up()
- if turtle.getItemCount(useSlot) <=1 then
- turtle.select(cobleChestSlot)
- turtle.placeUp()
- turtle.select(useSlot)
- turtle.suckUp(64)
- turtle.select(cobleChestSlot)
- turtle.digUp()
- turtle.select(useSlot)
- turtle.placeDown()
- else
- turtle.select(useSlot)
- turtle.placeDown()
- end
- end
- turtle.select(enderChestSlot)
- turtle.placeUp()
- turtle.select(useSlot)
- turtle.dropUp(turtle.getItemCount(slot))
- turtle.select(enderChestSlot)
- turtle.digUp()
- end
- function nextwell() -- move to the next well
- for j=0,4 do
- turtle.forward()
- end
- end
- function firstWell(nb) -- move to the next well
- for i=1,nb do
- turtle.forward()
- end
- end
- function start(nbrPuits, turtleType)
- if(turtleType == 1) then
- print("En cours...")
- elseif(turtleType == 2) then
- firstWell(3)
- print("En cours...")
- elseif(turtleType == 3) then
- firstWell(1)
- print("En cours...")
- elseif(turtleType == 4) then
- firstWell(4)
- print("En cours...")
- else
- firstWell(2)
- print("En cours...")
- end
- for i=1,nbrPuits do
- print("boucle main")
- refuelIfEmpty()
- depth = well()
- print("profondeur :")
- print(depth)
- up(depth)
- nextwell()
- end
- print("Terminee")
- end
- -------------
- --Main Prog
- -------------
- local depth = 0
- local nbrPuits
- local turtleType
- print("Quarry v0.1 Alpha")
- print("Type de la turtle : 1 a 5. (Syncro)")
- turtleType = tonumber(read())
- print("Nombre de puits :")
- nbrPuits = tonumber(read())
- if (turtleType < 1) or (turtleType>5) or (nbrPuits>64) then
- print("Erreur : Reboot")
- sleep(5)
- os.reboot()
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Quarry v0.1 Alpha")
- print("Run...")
- start(nbrPuits, turtleType)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement