Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x=1
- local y=0
- local z=1
- local d=1
- local h=5
- local dLigne=1
- local slotTerre = 1
- local slotMur = 9
- local slotFuel = 16
- local niveauFuelMini = 200
- local niveauStockFuelMini = 5
- local surface = 0
- local action = 0
- local resultat1,resultat2=0,0
- function inventaire()
- local success,data=true,{name="",metadata=0}
- repeat
- print("Pour niveler le terrain, taper 1.")
- print("Pour niveler le terrain et construire un mur d'enceinte, taper 2.")
- action = tonumber(read())
- until action==1 or action==2
- repeat
- print("Sur quel surface de terrain voulez-vous travailler ? (Minimum 5)")
- surface = tonumber(read())
- if surface==tonumber("") then surface=0 end
- until surface>=5
- turtle.turnLeft()
- repeat
- print("Merci de placer un coffre en face de la tortue. Il servira a completer son inventaire avec les materiaux designer ci-apres.")
- print("Lorsque c'est fait, appuye sur une touche.")
- read()
- success,data=turtle.inspect()
- sleep(0.1)
- until data.name=="minecraft:chest"
- turtle.turnLeft()
- repeat
- print("Merci de placer un coffre en face de la tortue. Il servira a recharger la tortue en combustible.")
- print("Lorsque c'est fait, appuye sur une touche.")
- read()
- success,data=turtle.inspect()
- sleep(0.1)
- until data.name=="minecraft:chest"
- turtle.turnLeft()
- if action==2 then
- repeat
- print("Merci de placer un coffre en face de la tortue. Il servira a completer son inventaire avec les materiaux designer ci-apres.")
- print("Lorsque c'est fait, appuye sur une touche.")
- read()
- success,data=turtle.inspect()
- sleep(0.1)
- until data.name=="minecraft:chest"
- end
- turtle.turnLeft()
- resultat1 = 3*surface*surface-10
- repeat
- print("Merci de prevoir dans le coffre a GAUCHE de la tortue "..resultat1.." blocs de terre et 10 blocs dans le slot "..slotTerre..".")
- print("Si necessaire, completer les inventaires et appuyer sur une touche.")
- read()
- until turtle.getItemCount(slotTerre)>=10
- if action==2 then
- resultat2 = ((surface-3)*20)+((surface-1)*4)-10
- repeat
- print("Merci de prevoir dans le coffre a DROITE de la tortue "..resultat2.." blocs d'obsidienne et 10 blocs dans le slot"..slotMur..".")
- print("Si necessaire, completer les inventaires et appuyer sur une touche.")
- read()
- until turtle.getItemCount(slotMur)>=10
- end
- repeat
- print("Merci de preparer 10 combustibles dans l'inventaire de la tortue (Slot 16). Completer egalement le coffre derriere la tortue.")
- print("Lorsque c'est fait, appuye sur une touche.")
- read()
- until turtle.getItemCount(slotFuel)>=10
- print("Appuyez sur n'importe quels touches pour commencer le terrassement.")
- read()
- end
- function testZ1()
- local success, data=turtle.inspectDown()
- stockTerre()
- if success then
- if data.name=="minecraft:dirt" or data.name=="minecraft:grass" then
- else
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- refuel()
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- refuel()
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotTerre)
- turtle.placeDown()
- turtle.up()
- z=z+1
- refuel()
- turtle.select(slotTerre)
- turtle.placeDown()
- turtle.up()
- z=z+1
- refuel()
- turtle.select(slotTerre)
- turtle.placeDown()
- end
- else
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- refuel()
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- refuel()
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotTerre)
- turtle.placeDown()
- turtle.up()
- z=z+1
- refuel()
- turtle.select(slotTerre)
- turtle.placeDown()
- turtle.up()
- z=z+1
- refuel()
- turtle.select(slotTerre)
- turtle.placeDown()
- end
- end
- function testZ4()
- local testFin=false
- stockMur()
- if testFin==false and x==1 then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- testFin=true
- end
- if testFin==false and x==2 and y>1 and y<surface then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- testFin=true
- end
- if testFin==false and x==surface-1 and y>1 and y<surface then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- testFin=true
- end
- if testFin==false and x==surface then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- testFin=true
- end
- if testFin==false and y==1 then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- testFin=true
- end
- if testFin==false and y==2 and x>1 and x<surface then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- testFin=true
- end
- if testFin==false and y==surface-1 and x>1 and x<surface then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- testFin=true
- end
- if testFin==false and y==surface then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- testFin=true
- end
- end
- function ligne()
- local fin = 1
- if d == 1 then
- fin = surface
- else
- fin = 1
- end
- while y ~= fin do
- if z == 1 then
- testZ1()
- end
- if z == 2 then
- stockMur()
- if x==2 and y>1 and y<surface then
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- refuel()
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- refuel()
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- turtle.up()
- z=z+1
- refuel()
- turtle.select(slotMur)
- turtle.placeDown()
- turtle.up()
- z=z+1
- refuel()
- turtle.select(slotMur)
- turtle.placeDown()
- end
- if x==surface-1 and y>1 and y<surface then
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- refuel()
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- refuel()
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- turtle.up()
- z=z+1
- refuel()
- turtle.select(slotMur)
- turtle.placeDown()
- turtle.up()
- z=z+1
- refuel()
- turtle.select(slotMur)
- turtle.placeDown()
- end
- if 2<x and x<surface-1 then
- if y==2 or y==surface-1 then
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- refuel()
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- refuel()
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- turtle.up()
- z=z+1
- refuel()
- turtle.select(slotMur)
- turtle.placeDown()
- turtle.up()
- z=z+1
- refuel()
- turtle.select(slotMur)
- turtle.placeDown()
- end
- end
- end
- if z == 3 then
- stockMur()
- if x==2 and y>1 and y<surface then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- end
- if x==surface-1 and y>1 and y<surface then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- end
- if 2<x and x<surface-1 then
- if y==2 or y==surface-1 then
- turtle.attackDown()
- turtle.digDown()
- turtle.select(slotMur)
- turtle.placeDown()
- end
- end
- end
- if z == 4 then
- testZ4()
- end
- turtle.attack()
- turtle.dig()
- turtle.forward()
- if d == 1 then
- y = y+1
- else
- y = y-1
- end
- refuel()
- end
- return true
- end
- function changementLigne()
- local dSave = d
- if z==1 then testZ1() end
- if z==4 then testZ4() end
- while dSave ~= 2 do
- if d==1 then
- turtle.turnRight()
- dSave = dSave+1
- end
- if d==3 then
- turtle.turnLeft()
- dSave = dSave-1
- end
- if dSave > 4 then
- dSave = 1
- end
- end
- turtle.attack()
- turtle.dig()
- turtle.forward()
- x = x+1
- refuel()
- if d == 1 then
- d = 3
- else
- d = 1
- end
- while dSave ~= d do
- if d==3 then
- turtle.turnRight()
- dSave = dSave+1
- end
- if d==1 then
- turtle.turnLeft()
- dSave = dSave-1
- end
- if dSave > 4 then
- dSave = 1
- end
- end
- return true
- end
- function deplacement(dx,dy,dz,dd)
- local td=0
- while z~=h do
- turtle.attackUp()
- turtle.digUp()
- turtle.up()
- z = z+1
- end
- if y~=dy then
- if y<dy then td=1 else td=3 end
- while d~=td do
- turtle.turnRight()
- d = d+1
- if d > 4 then
- d = 1
- end
- end
- end
- while y~=dy do
- turtle.attack()
- turtle.dig()
- turtle.forward()
- if d == 1 then
- y = y+1
- else
- y = y-1
- end
- end
- if x~=dx then
- if x<dx then td=2 else td=4 end
- while d~=td do
- turtle.turnRight()
- d = d+1
- if d > 4 then
- d = 1
- end
- end
- end
- while x~=dx do
- turtle.attack()
- turtle.dig()
- turtle.forward()
- if d == 2 then
- x = x+1
- else
- x = x-1
- end
- end
- while z~=dz do
- if z<dz then
- turtle.attackUp()
- turtle.digUp()
- turtle.up()
- z=z+1
- end
- if z>dz then
- turtle.attackDown()
- turtle.digDown()
- turtle.down()
- z=z-1
- end
- end
- while d~=dd do
- if d<dd then
- turtle.turnRight()
- d=d+1
- end
- if d>dd then
- turtle.turnLeft()
- d=d-1
- end
- end
- end
- function stockTerre()
- local xSv = x
- local ySv = y
- local zSv = z
- local dSv = d
- local nb=1
- if turtle.getItemCount(slotTerre)<10 then
- slotTerre=slotTerre+1
- end
- if turtle.getItemCount(7)<5 then
- deplacement(1,0,1,4)
- for i=1,7,1 do
- turtle.select(i)
- nb=turtle.getItemSpace()
- turtle.suck(nb)
- end
- deplacement(xSv,ySv,zSv,dSv)
- slotTerre=1
- end
- end
- function stockMur()
- local xSv = x
- local ySv = y
- local zSv = z
- local dSv = d
- local nb=1
- if turtle.getItemCount(slotMur)<10 then
- slotMur=slotMur+1
- end
- if turtle.getItemCount(14)<5 then
- deplacement(1,0,1,2)
- for i=9,14,1 do
- turtle.select(i)
- nb=turtle.getItemSpace()
- turtle.suck(nb)
- end
- deplacement(xSv,ySv,zSv,dSv)
- slotMur=9
- end
- end
- function definitionSlot()
- for i=2,8,1 do
- turtle.select(slotTerre)
- turtle.transferTo(i,1)
- end
- for i=10,15,1 do
- turtle.select(slotMur)
- turtle.transferTo(i,1)
- end
- end
- function refuel()
- while turtle.getFuelLevel() < niveauFuelMini do
- turtle.select(slotFuel)
- turtle.refuel(1)
- if turtle.getItemCount(slotFuel) < niveauStockFuelMini then
- return rechargeFuel()
- end
- end
- end
- function rechargeFuel()
- local xSv = x
- local ySv = y
- local zSv = z
- local dSv = d
- local nb=1
- deplacement(1,0,1,3)
- turtle.select(slotFuel)
- nb=64-turtle.getItemCount()
- turtle.suck(nb)
- deplacement(xSv,ySv,zSv,dSv)
- return true
- end
- function videInventaire()
- local xSv = x
- local ySv = y
- local zSv = z
- local dSv = d
- deplacement(1,0,1,4)
- for i=1,8 do
- turtle.select(i)
- while turtle.getItemCount(i) > 0 do
- turtle.drop(turtle.getItemCount(i))
- sleep(0.2)
- end
- end
- turtle.turnLeft()
- turtle.select(slotFuel)
- while turtle.getItemCount(slotFuel) > 0 do
- turtle.drop(turtle.getItemCount(slotFuel))
- sleep(0.2)
- end
- turtle.turnLeft()
- for i=9,15 do
- turtle.select(i)
- while turtle.getItemCount(i) > 0 do
- turtle.drop(turtle.getItemCount(i))
- sleep(0.2)
- end
- end
- turtle.turnLeft()
- end
- --********************************************--
- --********** Programme principal *************--
- --********************************************--
- local f=0
- inventaire()
- print("Terrassement en cours...")
- definitionSlot()
- if action == 1 then
- f = 2
- stockTerre()
- else
- f = 5
- stockTerre()
- stockMur()
- end
- refuel()
- turtle.forward()
- y=y+1
- while z~=f do
- while x~=surface+1 do
- ligne()
- changementLigne()
- end
- deplacement(1,1,z,1)
- turtle.attackUp()
- turtle.digUp()
- turtle.up()
- z=z+1
- refuel()
- end
- videInventaire()
- print("Terrassement terminer!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement