Advertisement
Guest User

Energy

a guest
Apr 24th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.09 KB | None | 0 0
  1.     shell.run("clear")
  2.     energy="none"
  3.     monitor="none"
  4.     local peripheralList = peripheral.getNames()
  5.     monnum=0
  6.     enrnum=0
  7.    
  8.     title=""
  9.    
  10.     tablica = {
  11.     monitor ={"test","test"},
  12.     energy={"test","test"}
  13.     }
  14.    
  15.     Resonant_Cell = {
  16.     List = {},
  17.     Ilosc = 0,
  18.     Merge = false
  19.     }
  20.    
  21.     Cuby = {
  22.     List = {}
  23.     }
  24.    
  25.    
  26.         print ("Wybierz Monitor:")
  27.         for Index = 1, #peripheralList do
  28.             if string.find(peripheralList[Index], "monitor") then
  29.                 monnum = monnum + 1
  30.                 tablica.monitor[monnum]=peripheralList[Index]
  31.                 print (monnum..". " ..peripheralList[Index])
  32.             end
  33.         end --for
  34.     monitor = tostring(tablica.monitor[tonumber(io.read())])
  35.    
  36.       function centerText(text,yVal)
  37.         length = string.len(text)
  38.         minus = math.floor(27-length)
  39.         x = math.floor(minus/2)
  40.         monitor.setCursorPos(x+1,yVal)
  41.         monitor.write(text)
  42.   end
  43.    
  44.     shell.run("clear")
  45.    
  46.         print ("Wybierz Magazyn Energi:")
  47.         for Index = 1, #peripheralList do
  48.             if string.find(peripheralList[Index], "cell") then
  49.                 enrnum = enrnum + 1
  50.                 tablica.energy[enrnum]=peripheralList[Index]
  51.                 print (enrnum..". " ..peripheralList[Index])
  52.                 if string.find(peripheralList[Index], "resonant") then
  53.                     Resonant_Cell.Ilosc = Resonant_Cell.Ilosc + 1
  54.                     Resonant_Cell.List[Resonant_Cell.Ilosc] = peripheralList[Index]
  55.                 end
  56.             elseif string.find(peripheralList[Index], "Cube") then
  57.                 enrnum = enrnum + 1
  58.                 tablica.energy[enrnum]=peripheralList[Index]
  59.                 print (enrnum..". " ..peripheralList[Index])
  60.             elseif string.find(peripheralList[Index], "Mekanism") then
  61.                 enrnum = enrnum + 1
  62.                 tablica.energy[enrnum]=peripheralList[Index]
  63.                 print (enrnum..". " ..peripheralList[Index])
  64.             elseif string.find(peripheralList[Index], "capacitorbank") then
  65.                 enrnum = enrnum + 1
  66.                 tablica.energy[enrnum]=peripheralList[Index]
  67.                 print (enrnum..". " ..peripheralList[Index])
  68.             end
  69.         end        
  70.     energy = tostring(tablica.energy[tonumber(io.read())])
  71.    
  72.     --if Resonant_Cell.Ilosc > 1 then
  73.     --  shell.run("clear")
  74.     --  print ("Znaleziono wiecej niz jeden Resonant Cell, Czy chcesz je polaczyc ? (Ilosc: "..Resonant_Cell.Ilosc..")")
  75.     --  if io.read() == "tak" then
  76.     --      Resonant_Cell.Merge = true
  77.     --      for x = 1, Resonant_Cell.Ilosc do
  78.     --          energy = tostring(Resonant_Cell.List[x])
  79.     --      end
  80.     --      Resonant_Cell.Merge = true
  81.     --  elseif io.read() == "nie" then
  82.     --      shell.run("clear")
  83.     --      print("Wybierz numer:")
  84.     --      energy = tostring(tablica.energy[tonumber(io.read())])
  85.     --     
  86.     --  else
  87.     --      energy = tostring(tablica.energy[tonumber(io.read())])
  88.     --      shell.run("clear")
  89.     --      if string.find(energy, "resonant") then
  90.     --          title = "Resonant Energy Cell"
  91.     --      end
  92.     -- 
  93.     --  end
  94.     --end
  95.    
  96.     if Resonant_Cell.Merge == true then
  97.         for x = 1, Resonant_Cell.Ilosc do
  98.             Cuby.List[x] = peripheral.wrap(Resonant_Cell.List[x])
  99.         end
  100.         shell.run("clear")
  101.         print("Poloczono: " ..Resonant_Cell.Ilosc.." Resonant Cell!")
  102.         title = "Resonant Energy Celle"
  103.     end
  104.    
  105.     energy = peripheral.wrap(energy)
  106.     monitor = peripheral.wrap(monitor)
  107.    
  108.     monitor.setBackgroundColour(colors.black)
  109.     monitor.setTextColour(colors.red)
  110.     monitor.setTextScale(1.0)
  111.     monitor.setCursorPos(1,1)
  112.     centerText(string.rep(" ",string.len(title)+2),1)
  113.     centerText(title,1)
  114.    
  115. while true do
  116.  
  117.     if Resonant_Cell.Merge == true then
  118.         maxRF = Cuby.List[1].getMaxEnergyStored("unknown")
  119.         curRF = Cuby.List[1].getEnergyStored("unknown")
  120.     end    
  121.  
  122.            
  123.        
  124.         maxRF = energy.getMaxEnergyStored("unknown")
  125.         curRF = energy.getEnergyStored("unknown")
  126.    
  127.         curKRF = curRF / 1000
  128.         curMRF = curKRF / 1000
  129.         curGRF = curMRF / 1000
  130.        
  131.         if curRF < 9999 then
  132.             monitor.setBackgroundColour(colors.black)
  133.             monitor.setTextColour(colors.blue)
  134.             centerText("Energia: "..curKRF.." KRF",3)
  135.         elseif curRF < 99999999 then
  136.             monitor.setBackgroundColour(colors.black)
  137.             monitor.setTextColour(colors.blue)
  138.             centerText("Energia: "..curMRF.." MRF",3)
  139.         elseif curRF < 9999999999999 then
  140.             monitor.setBackgroundColour(colors.black)
  141.             monitor.setTextColour(colors.blue)
  142.             centerText("Energia: "..curGRF.." GRF",3)
  143.         end
  144.  
  145. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement