Advertisement
se7enek

Napelnianie tankow by se7en

Jun 14th, 2014
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. -- Ustawienia
  2. odswiez = 40
  3. slot = 1
  4. tryb = 1
  5. -- tryb = 1 -> napelnianie
  6. -- tryb = 0 -> oproznianie
  7.  
  8. -- Start
  9. if tryb == 1 then
  10.  print("Rozpoczeto Napelnianie Zbiornikow.")
  11. else
  12.  print("Rozpoczeto Oproznianie Zbiornikow.")
  13. end
  14. sleep(1)
  15. if not turtle.detect() then
  16.   print("Nie wykryto zadnego zbiornika, stawianie zbiornika...")
  17.   turtle.select(slot)
  18.   if turtle.getItemCount(slot) == 0 then
  19.     print("Brak zbiornikow, wylaczanie programu.") return
  20.   end
  21.   turtle.place()
  22. end
  23. sleep(1)
  24. t = peripheral.wrap("front")
  25. if t==nil then
  26.   print("Nie znaleziono zadnego zbiornika") return
  27. end
  28. while true do
  29.   value = 0  max = 0
  30.   ti = t.getTankInfo("front")
  31.   for i,j in pairs(ti) do
  32.     for name,data in pairs(j) do
  33.       if name=="capacity" then max = data
  34.       elseif name=="amount" then teraz = data
  35.       end      
  36.     end
  37.   end
  38.     if tryb == 1 then
  39.       if teraz == max then
  40.         print("Zbiornik pelen. Podmienianie zbiornika na pusty...")
  41.         sleep(1)
  42.         turtle.dig()
  43.         if turtle.getItemCount(slot) == 0 then
  44.           print("Brak nowych zbiornikow, wylaczanie programu.") return
  45.         end
  46.         else
  47.          
  48.           print("Zbiornik: "..math.floor(teraz/max*100).."% ("..teraz.."/"..max..")")
  49.       end
  50.     else
  51.       if teraz == 0 then
  52.         print("Zbiornik pusty. Podmienianie zbiornika na pelny...")
  53.         sleep(1)
  54.         turtle.dig()
  55.         if turtle.getItemCount(slot) == 0 then
  56.           print("Brak kolejnych zbiornikow, wylaczanie programu.") return
  57.         end
  58.         else
  59.          
  60.           print("Zbiornik: "..math.floor(teraz/max*100).."% ("..teraz.."/"..max..")")
  61.       end
  62.     end
  63.     turtle.select(slot)
  64.     turtle.place()
  65.  
  66.   sleep(odswiez)
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement