Suppenbiatch

Turbine new

Jun 22nd, 2019
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. local monitor = peripheral.wrap("monitor_2")
  2. local turbine = peripheral.wrap("Industrial Turbine_0")
  3.  
  4. function formateNumber(n) --http://richard.warburton.it
  5.     if type(n) == "number" then
  6.         n = string.format("%.f", tostring(n))
  7.     else
  8.         n = string.format("%.f", n)
  9.     end
  10.     local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$');
  11.     return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right;
  12. end
  13. function round(num, idp)
  14.   local mult = 10^(idp or 0);
  15.   return math.floor(num * mult + 0.5) / mult;
  16. end
  17.  
  18. monitor.clear()
  19. monitor.setTextColor(colors.combine(colors.orange, colors.yellow))
  20. monitor.setTextScale(1)
  21.  
  22. while true do
  23.  
  24.     local isOn = turbine.isFormed()
  25.     local SteamInv = turbine.getSteam()
  26.     local SteamFlowRate = turbine.getFlowRate()
  27.     local SteamInput = turbine.getSteamInput()
  28.    
  29.     local PowerOutput = SteamFlowRate * 40
  30.    
  31.     monitor.setCursorPos(2,6)
  32.     monitor.clearLine()
  33.     if isOn then
  34.         monitor.setTextColor(colors.lime)
  35.         monitor.write("Turbine is FORMED")
  36.     else
  37.         monitor.setTextColor(colors.red)
  38.         monitor.write("Turbine is NOT FORMED")
  39.     end
  40.    
  41.     monitor.setTextColor(colors.combine(colors.orange, colors.yellow))
  42.    
  43.     monitor.setCursorPos(2,9)
  44.     monitor.clearLine()
  45.     monitor.write("Turbine is consuming " .. formateNumber(SteamInput) .. " mB/t steam.")
  46.    
  47.     monitor.setCursorPos(2,12)
  48.     monitor.clearLine()
  49.     monitor.write("Turbine is producing " .. formateNumber(PowerOutput) .. " RF/t.")
  50.  
  51.  
  52. sleep(0.1)
  53. end
Add Comment
Please, Sign In to add comment