SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local sizeX, sizeY = term.getSize()
  2. os.unloadAPI("sensorsUI")
  3. os.loadAPI("/rom/apis/sensorsUI")
  4. os.unloadAPI("sensors")
  5. os.loadAPI("/rom/apis/sensors")
  6. os.unloadAPI("sensorsData")
  7. os.loadAPI("/rom/apis/sensorsData")
  8.  
  9. local arg = {...};
  10.  
  11.  
  12.  
  13. --[[
  14.     Dashboard Parameters
  15. ]]--
  16. -- sensor name
  17. local sensor= arg[1] or "Sensor";
  18. -- dashboard title
  19. local title="Reactor Dashboard";
  20.  
  21. -- refresh timer
  22. local refresh=2
  23. -- probe name
  24. --local probe="Reactor";
  25.  
  26. local maxx=0;
  27. local side = sensors.getController()
  28. local monside="none",mon ; --= sensorsUI.getMonitor();
  29. local targets = sensors.getAvailableTargetsforProbe(side,sensor,"Reactor");
  30. local target = targets[1]
  31. local targets_mfsu = sensors.getAvailableTargetsforProbe(side,sensor,"EUStorage");
  32. --[[
  33. if #targets_mfsu>0 then
  34.     sensorsUI.printPaged ("[Probe:"..p.. "] [Available Targets:"..#targets_mfsu.."]");
  35.     for i,v in ipairs(targets_mfsu) do
  36.         sensorsUI.printPaged ("  "..v)
  37.     end
  38. end
  39. ]]--
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. -- main program
  48.  
  49. if monside~="none" then
  50.     sensorsUI.writeAt(1,sizeY,"Press Spacebar to exit")
  51.     mon.setTextScale(1);
  52.     term.redirect(mon);
  53. end
  54. local val1=0;
  55. local maxval1=0;
  56. local done=false;
  57. local e = sensorsData.getProbe("ic2","reactor");
  58. local eus =sensorsData.getProbe("ic2","eustorage");
  59. local reactor = sensors.getSensorReadingAsDict(side,sensor,target,"Reactor")
  60. local content = sensors.getSensorReadingAsDict(side,sensor,target,"ReactorContent")
  61. --for i,v in pairs(content) do
  62. --  print(v)
  63. --end
  64.  
  65.  
  66. local mfsu={};
  67.  
  68. for ind,tg in ipairs(targets_mfsu) do
  69.     mfsu[ind] = sensors.getSensorReadingAsDict(side,sensor,targets_mfsu[ind],"EUStorage")
  70. end
  71. --local mfsu1 = sensors.getSensorReadingAsDict(side,sensor,targets_mfsu[1],"EUStorage")
  72. local itemMap = sensors.getItemsInfo({"Coolant Cell","Uranium Cell","Integrated Heat Disperser","Integrated Reactor Plating","Ice","Water Bucket","Bucket"},content);
  73.  
  74.  
  75.  
  76. local timer1=os.startTimer(refresh)
  77. local count=1;
  78. local  progress={"-","\\","|","/"};
  79. term.clear()
  80. sensorsUI.writeAt(1,1,title)
  81. if monside=="none" then
  82.     sensorsUI.writeAt(1,sizeY,"Press Spacebar to exit")
  83. end
  84. local rate1=0;
  85. local rate2=0;
  86. local water_prev=itemMap["Water Bucket"].qty or 0;
  87. local ice_prev=itemMap["Ice"].qty or 0;
  88.  
  89. while not done do
  90.     sensorsUI.hr(2)
  91.     sensorsUI.hRadio(sizeX-23,1,"Chambers",reactor[e.size.val],{1,2,3,4,5,6});
  92.     sensorsUI.writeAt(1,3,e.energy.label.." : "..reactor[e.energy.val]);
  93.     sensorsUI.hBar(1,4,10,e.heat.label,reactor[e.heat.val],reactor[e.size.val]*1000+10000);
  94.     sensorsUI.vBar(sizeX-8,sizeY-1,12,"Fuel",itemMap["Uranium Cell"].qty*10000-itemMap["Uranium Cell"].dmg,itemMap["Uranium Cell"].qty*10000);
  95.    
  96.     sensorsUI.writeAt(1,6,"Reactor Components")
  97.     sensorsUI.hBar(1,7,10,"Coolant Cells",itemMap["Coolant Cell"].qty*10000-itemMap["Coolant Cell"].dmg,itemMap["Coolant Cell"].qty*10000);
  98.     sensorsUI.hBar(1,8,10,"Heat Dispersers",itemMap["Integrated Heat Disperser"].qty*10000-itemMap["Integrated Heat Disperser"].dmg,itemMap["Integrated Heat Disperser"].qty*10000);
  99.  -- sensorsUI.hBar(1,9,10,"Reactor Plating",itemMap["Integrated Reactor Plating"].qty*10000-itemMap["Integrated Reactor Plating"].dmg,itemMap["Integrated Reactor Plating"].qty*10000);
  100.     -- consumables
  101.     local freeSlots=(reactor[e.size.val] +3 ) *6 - itemMap.total;
  102.     -- totalSlots = itemMap.total
  103.     -- empty buckets:  itemMap["Bucket"].qty
  104.     -- water buckets:  itemMap["Water Bucket"].qty
  105.    
  106.     -- calc rate
  107.     --rate1 = itemMap["Water Bucket"].qty - water_prev ;
  108.     --water_prev = itemMap["Water Bucket"].qty;
  109.     --rate2 = itemMap["Ice"].qty - ice_prev;
  110.     --ice_prev=itemMap["Ice"].qty;
  111.    
  112.     --sensorsUI.writeAt(1,10,"Water       :"..itemMap["Water Bucket"].qty.. "  ["..rate1.."/"..refresh.."sec]");
  113.     --sensorsUI.writeAt(1,11,"Ice         :"..itemMap["Ice"].qty.." ["..rate2.."/"..refresh.."sec]");
  114.  
  115.     --sensorsUI.writeAt(1,12,rate1.."  Empty: [Slots:"..freeSlots.."] [Buckets:"..itemMap["Bucket"].qty.."]")
  116.    
  117.     --eu storage
  118.     sensorsUI.writeAt(1,10,"EU Storage")
  119.     for ind,tg in ipairs(targets_mfsu) do
  120.         maxx=mfsu[ind][eus.storage.maxval];
  121.         if maxx==40000 then
  122.             sensorsUI.hBar(1,10+ind,10,ind.."-BATBOX",mfsu[ind][eus.storage.val],mfsu[ind][eus.storage.maxval]);
  123.         elseif maxx==600000 then
  124.             sensorsUI.hBar(1,10+ind,10,ind.."-MFE",mfsu[ind][eus.storage.val],mfsu[ind][eus.storage.maxval]);
  125.         else
  126.             sensorsUI.hBar(1,10+ind,10,ind.."-MFSU",mfsu[ind][eus.storage.val],mfsu[ind][eus.storage.maxval]);
  127.         end
  128.     end
  129.  
  130. local round1=0;
  131. val1=mfsu[2][eus.storage.val];
  132.  
  133. if val1<3000000 then
  134.   redstone.setOutput("left",false);
  135. elseif val1>8000000 then
  136.   redstone.setOutput("left",true);
  137. end
  138.  
  139.  
  140. if redstone.getOutput("left")==true then
  141.     term.setCursorPos(4 ,15);
  142.     term.write("Mass Fabricator is Running");
  143. --  writeAt(2,15,"Mass Fabricator is Running")
  144. else
  145.     term.setCursorPos(4 ,15);
  146.     term.write("Mass Fabricator isnt Running");
  147. -- writeAt(2,15,"Mass Fabricator isnt Running")
  148. end
  149. --maxval1=mfsu[2][eus.storage.maxval];
  150.     --eu storage
  151.     --if round(mfsu[2][eus.storage.val]*100/mfsu[2][eus.storage.maxval],1) >
  152.  -- round1=round(mfsu[2][eus.storage.val]*100/mfsu[2][eus.storage.maxval],1);
  153.  
  154.    
  155.  
  156.  
  157. evt,k = os.pullEvent()
  158.     if evt=="timer" and k == timer1 then
  159.         timer1=os.startTimer(refresh)
  160.         -- update readings
  161.         reactor = sensors.getSensorReadingAsDict(side,sensor,target,"Reactor")
  162.         content = sensors.getSensorReadingAsDict(side,sensor,target,"ReactorContent")
  163.         itemMap = sensors.getItemsInfo({"Coolant Cell","Uranium Cell","Integrated Heat Disperser","Integrated Reactor Plating","Ice","Water Bucket","Bucket"},content);
  164.         for ind,tg in ipairs(targets_mfsu) do
  165.             mfsu[ind] = sensors.getSensorReadingAsDict(side,sensor,targets_mfsu[ind],"EUStorage")
  166.         end
  167.        
  168.     elseif evt=="key" and (k == 28 or k ==57) then
  169.         done=true
  170.     end
  171.    
  172.     sensorsUI.writeAt(string.len(title)+2,1,progress[count])
  173.     sensorsUI.writeAt(2,15,progress[count])
  174.  
  175.     count = count+1;
  176.     if count>3 then count=1 end
  177.  
  178. end
  179. term.restore();
  180. term.setCursorPos(1,sizeY)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top