Advertisement
Armitige

Test Reactor/Turbine Script

Nov 5th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. function wrapThis(thing, x)
  2.     local wrapped, i = nil, x
  3.     while wrapped == nil and i <= 100 do
  4.         wrapped = peripheral.wrap(thing.."_"..i)
  5.         i = i + 1
  6.     end
  7.     if wrapped == nil then
  8.         return nil
  9.     else
  10.         return wrapped
  11.     end
  12. end
  13.  
  14. function round(num, idp)
  15.     local mult = 10^(idp or 0)
  16.     return math.floor(num * mult + 0.5) / mult
  17. end
  18.  
  19. while true do
  20. local r = wrapThis("BigReactors-Reactor", 0)
  21. local t= {}
  22. for i = 0, 3 do
  23.     t[i] = wrapThis("BigReactors-Turbine", i)
  24. end
  25. local mon = peripheral.wrap("bottom")
  26.  
  27. mon.clear()
  28. mon.setCursorPos(1,1)
  29. mon.write("Reactor Temp: "..round(r.getCasingTemperature(),1).."°C")
  30. mon.setCursorPos(1,2)
  31. mon.write("Fuel Consumption: "..round(r.getFuelConsumedLastTick(),3).."mB/t")
  32. for i = 0, 3 do
  33.     tur = i + 1
  34.     y = i + 3
  35.     mon.setCursorPos(1,y)
  36.     mon.write("Turbine "..tur..": "..round(t[i].getRotorSpeed(),1).."RPM")
  37.  
  38. end
  39. os.sleep(5)
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement