stefa168

"Simple" mining program V1.5.1

Jun 19th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.75 KB | None | 0 0
  1. local Version = "1.5.2"
  2.  
  3. --Changelog:
  4. --Version 1.5.2: Turtle didn't dig up. Now it does
  5. --Version 1.5.1: Fixed a bug in a function
  6. --Version 1.5: More compact and digs correctly now
  7. --Version 1.4: Bug of 1.3 fixed :)
  8. --Version 1.3 More fixes, code more compact, a new bug
  9. --Version 1.1: Fixes
  10. --Version 1.0: First Release
  11.  
  12.   shell.run('clear')
  13.    
  14.   local bslot, fuel, fuelV, contatoreDritto, contatoreSopra, contatoreToT, pulsante, lang, pulsanteSX, pulsanteDX = 1, 2, 0, 0, 0, 0, 28, false, 203, 205
  15.   local str1, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11, str12, str13
  16.   local str1IT = "INIZIALIZZAZIONE PROGRAMMA, ATTENDERE :)"
  17.   local str1EN = "PROGRAM INITIALIZATION, PLEASE WAIT :)"
  18.   local str2IT = "Programma per scavare"
  19.   local str2EN = "Digging Program"
  20.   local str3IT = "Versione "
  21.   local str3EN = "Version "
  22.   local str4IT = "Realizzato da stefa168"
  23.   local str4EN = "Made By stefa168"
  24.   local str5IT = "Prima di tutto, inserisci nello slot 2 del carburante!"
  25.   local str5EN = "First, put in slot 2 some fuel!"
  26.   local str6IT = "Fai attenzione, perchè se il carburante finisce dovrai riavviare il programma e rimetterne altro!"
  27.   local str6EN = "Be careful, because if fuel ends you will have to restart the program and put more fuel!"
  28.   local str7IT = "Quando l'hai messo, premi INVIO"
  29.   local str7EN = "When you put it in, press ENTER"
  30.   local str8IT = "Attendi un secondo mentre utilizzo il carburante che hai messo..."
  31.   local str8EN = "Hold on while I use the fuel you gave me..."
  32.   local str9IT = "Selezionato lo slot del carburante"
  33.   local str9EN = "Fuel slot selected"
  34.  
  35.  
  36.  
  37.  
  38.   function waitKey(par1)
  39.     while true do
  40.       local sEvent, param = os.pullEvent("key")
  41.       if sEvent == "key" then
  42.         if param == par1 then
  43.         break
  44.         end
  45.       end
  46.     end
  47.   end
  48.  
  49.   function scavaSopra(mex)
  50.     if turtle.detectUp() then
  51.       if mex then
  52.         turtle.digUp()
  53.         print("Scavo il blocco sopra..")
  54.         contatoreSopra = contatoreSopra + 1
  55.         print("Questo e' il blocco (sopra) numero "..tostring(contatoreSopra))
  56.         contatoreTot = contatoreSopra + contatoreDritto
  57.       else
  58.         turtle.digUp()
  59.         contatoreSopra = contatoreSopra + 1
  60.       end
  61.     end
  62.   end
  63.  
  64.   print("Hello! Ciao!")
  65.   print("Press the left keyboard arrow if you speak english!")
  66.   print("Se parli italiano, premi la freccia destra sulla tastiera!")
  67.  
  68.   while true do
  69.     local sEvent, param = os.pullEvent("key")
  70.     if sEvent == "key" then
  71.       if param == pulsanteSX then
  72.       str1 = str1EN
  73.       str2 = str2EN
  74.       str3 = str3EN
  75.       str4 = str4EN
  76.       str5 = str5EN
  77.       str6 = str6EN
  78.       str7 = str7EN
  79.       str8 = str8EN
  80.       str9 = str9EN
  81.       str10 = str10EN
  82.       str11 = str11EN
  83.       str12 = str12EN
  84.       str13 = str13EN
  85.       break
  86.       elseif param == pulsanteDX then
  87.       str1 = str1IT
  88.       str2 = str2IT
  89.       str3 = str3IT
  90.       str4 = str4IT
  91.       str5 = str5IT
  92.       str6 = str6IT
  93.       str7 = str7IT
  94.       str8 = str8IT
  95.       str9 = str9IT
  96.       str10 = str10IT
  97.       str11 = str11IT
  98.       str12 = str12IT
  99.       str13 = str13IT
  100.       break
  101.       end
  102.     end
  103.   end
  104.  
  105.   print(str1)
  106.   sleep(1)
  107.  
  108.   shell.run('clear')
  109.   print(str2)
  110.   print(str3..tostring(Version))
  111.   print(str4)
  112.   sleep(2)
  113.  
  114.   shell.run('clear')
  115.   print(str5)
  116.   print(str6)
  117.   print(str7)
  118.   waitKey(pulsante)
  119.  
  120.   shell.run('clear')
  121.  
  122.   print(str8)
  123.   turtle.select(fuel)
  124.   print(str9)
  125.   turtle.refuel()
  126.   print("Utilizzato il carburante")
  127.   fuelV = turtle.getFuelLevel()
  128.   print("Ora il livello del carburante e' "..tostring(fuelV).."!")
  129.  
  130.   turtle.select(bslot)
  131.   print("Selezionato lo slot primario!")
  132.   sleep(1)
  133.  
  134.   shell.run('clear')
  135.   print("Ora, per favore, metti in slot 1 il blocco che fermera' il programma.")
  136.   print("Quando l'hai fatto, premi INVIO")
  137.    
  138.   waitKey(pulsante)
  139.   shell.run('clear')
  140.  
  141.   print("Ok, inizio a scavare tra 5 secondi!")
  142.   sleep(2)
  143.   for i = 0,2 do
  144.     shell.run('clear')
  145.     print(3-i)
  146.     sleep(1)
  147.   end
  148.  
  149.   scavaSopra(false)
  150.  
  151.   shell.run('clear')
  152.  
  153.   while not turtle.compare() do
  154.     scavaSopra(true)
  155.     turtle.dig()
  156.     print("Scavo il blocco....")
  157.     contatoreDritto = contatoreDritto + 1
  158.     print("Questo e' il blocco (dritto) numero "..tostring(contatoreDritto))
  159.     print("Finora sono stati scavati "..tostring(contatoreTot).." blocchi in tutto!")
  160.     turtle.forward()
  161.   end
  162.   turtle.digUp()
  163.  
  164.   shell.run('clear')
  165.   print("Ho raggiunto la fine del mio percorso dopo aver scavato "..tostring(contatoreTot).." blocchi!")
  166.   print("Ora torno indietro!")
  167.    
  168.   for i=1, contatoreDritto do
  169.     turtle.back()
  170.   end
  171.   print("Ho finito il mio lavoro!")
  172.   sleep(3)
  173.   print("DEBUG: FINE PROGRAMMA")
Advertisement
Add Comment
Please, Sign In to add comment