Advertisement
Guest User

startup

a guest
Oct 31st, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.15 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. print("Executing Reactor Statistics...")
  4. mon = peripheral.wrap("top")
  5. reactor = peripheral.wrap("BigReactors-Reactor_0")
  6.  
  7. function explode(d,p)
  8.   local t, ll
  9.   t={}
  10.   ll=0
  11.   if(#p == 1) then return {p} end
  12.     while true do
  13.       l=string.find(p,d,ll,true) -- find the next d in the string
  14.       if l~=nil then -- if "not not" found then..
  15.         table.insert(t, string.sub(p,ll,l-1)) -- Save it in our array.
  16.         ll=l+1 -- save just after where we found it for searching next time.
  17.       else
  18.         table.insert(t, string.sub(p,ll)) -- Save what's left in our array.
  19.         break -- Break at end, as it should be, according to the lua manual.
  20.       end
  21.     end
  22.   return t
  23. end
  24.  
  25. while true do
  26.   mon.clear()
  27.   mon.setCursorPos(5,1)
  28.   mon.write("---------------------")
  29.   mon.setCursorPos(5,2)
  30.   mon.write("-    Base Power     -")
  31.   mon.setCursorPos(5,3)
  32.   mon.write("---------------------")
  33.  
  34.   -- Reactor Status
  35.   mon.setCursorPos(5,4)
  36.   mon.write("-  Status:")
  37.   if reactor.getActive() then
  38.     mon.setTextColor(colors.green)
  39.     mon.write("  Online")
  40.     mon.setTextColor(colors.white)
  41.     mon.write("  -")
  42.   else
  43.     mon.setTextColor(colors.red)
  44.     mon.write(" Offline")
  45.     mon.setTextColor(colors.white)
  46.     mon.write("  -")
  47.   end
  48.  
  49.   -- Fuel Reactivity
  50.   mon.setCursorPos(5,5)
  51.   local reacSplit = explode(".", tostring(reactor.getFuelReactivity()))
  52.   mon.write("-  Reactivity: ")
  53.   mon.setTextColor(colors.yellow)
  54.   mon.write(reacSplit[1])
  55.   mon.setTextColor(colors.white)
  56.   if string.len(reacSplit[1]) == 3 then
  57.     mon.write("  -")
  58.   else
  59.     mon.write("   -")
  60.   end
  61.  
  62.   -- Fuel Temperature
  63.   mon.setCursorPos(5,6)
  64.   mon.write("-  Fuel Temp: ")
  65.   ftSplit = explode(".", tostring(reactor.getFuelTemperature()))
  66.   mon.setTextColor(colors.red)
  67.   mon.write(ftSplit[1])
  68.   mon.setTextColor(colors.white)
  69.   if string.len(ftSplit[1]) == 4 then
  70.     mon.write("  -")
  71.   elseif string.len(ftSplit[1]) == 3 then
  72.     mon.write("   -")
  73.   elseif string.len(ftSplit[1]) == 2 then
  74.     mon.write("    -")
  75.   else
  76.     mon.write("     -")
  77.   end
  78.  
  79.   -- Case Temperature
  80.   mon.setCursorPos(5,7)
  81.   mon.write("-  Case Temp: ")
  82.   ctSplit = explode(".", tostring(reactor.getCasingTemperature()))
  83.   mon.setTextColor(colors.red)
  84.   mon.write(ctSplit[1])
  85.   mon.setTextColor(colors.white)
  86.   if string.len(ctSplit[1]) == 4 then
  87.     mon.write("  -")
  88.   elseif string.len(ctSplit[1]) == 3 then
  89.     mon.write("   -")
  90.   elseif string.len(ctSplit[1]) == 2 then
  91.     mon.write("    -")
  92.   else
  93.     mon.write("     -")
  94.   end
  95.  
  96.   -- RF/T
  97.   mon.setCursorPos(5,8)
  98.   mon.write("-  Energy /t: ")
  99.   ept = explode(".", tostring(reactor.getEnergyProducedLastTick()))
  100.   mon.setTextColor(colors.orange)
  101.   mon.write(ept[1])
  102.   mon.setTextColor(colors.white)
  103.   if string.len(ept[1]) == 4 then
  104.     mon.write("  -")
  105.   elseif string.len(ept[1]) == 3 then
  106.     mon.write("   -")
  107.   elseif string.len(ept[1]) == 2 then
  108.     mon.write("    -")
  109.   else
  110.     mon.write("     -")
  111.   end
  112.  
  113.   -- Complete Stats
  114.   mon.setCursorPos(5,9)
  115.   mon.write("---------------------")
  116.  
  117.   -- Yield to other processes
  118.   sleep(5)
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement