Advertisement
Guest User

reactormon

a guest
Aug 1st, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.81 KB | None | 0 0
  1.  
  2. -- Some functions
  3.  
  4. -- Gets a peripheral by name, so that
  5. -- we can connect to the reactor via a
  6. -- modem much easier
  7. function getPeripheral(thing)
  8.   local wrapped, i = nil, 0
  9.   while wrapped == nil and i <= 100 do
  10.     wrapped = peripheral.wrap(thing.."_"..i)
  11.     i = i + 1
  12.   end
  13.  
  14.   if wrapped == nil then
  15.     side = getDeviceSide(thing)
  16.     if side ~= nil then
  17.       return peripheral.wrap(side)
  18.     else
  19.       return nil
  20.     end
  21.   else
  22.     return wrapped
  23.   end
  24. end
  25.  
  26. -- Displays a data row in two columns
  27. function displayDataRow(monitor, lineNum, label, value)
  28.  
  29.   valueIndent = 20
  30.  
  31.   monitor.setCursorPos(1, lineNum)
  32.   monitor.write(label)
  33.   monitor.setCursorPos(valueIndent, lineNum)
  34.   monitor.write(value)
  35.  
  36. end
  37.  
  38. -- Rounds a number
  39. function round(number)
  40.  return math.floor(number + 0.5)
  41. end
  42.  
  43.  
  44. -- Start of actual program
  45.  
  46. local reactor = getPeripheral("BigReactors-Reactor")
  47. local monitor = peripheral.wrap("left")
  48.  
  49. if reactor == nil then
  50.  
  51.     print("Can't find reactor")
  52.  
  53. else
  54.  
  55.   if monitor == nil then
  56.  
  57.     print("Can't find monitor")                    
  58.  
  59.   else
  60.        
  61.     monitor.clear()
  62.    
  63.     displayDataRow(monitor,1,"Big Reactor Monitor","")
  64.     displayDataRow(monitor,2,"-------------------","")
  65.  
  66.     displayDataRow(monitor,4,"Reactor active:", reactor.getActive())
  67.  
  68.     displayDataRow(monitor,4,"Fuel temp:", round(reactor.getFuelTemperature()))
  69.     displayDataRow(monitor,5,"Casing temp:", round(reactor.getCasingTemperature()))
  70.     displayDataRow(monitor,6,"Fuel left:", reactor.getFuelAmount())
  71.     displayDataRow(monitor,7,"Reserve RF:",round(reactor.getEnergyStored()))
  72.     displayDataRow(monitor,8,"Fuel Reactivity:",reactor.getFuelReactivity().."%")
  73.     displayDataRow(monitor,9,"Fuel per tick:", reactor.getFuelConsumedLastTick())
  74.  
  75.   end
  76.  
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement