Advertisement
gpochy

reactor

Jan 19th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.54 KB | None | 0 0
  1. --os.loadAPI("button")
  2.  
  3. r = peripheral.wrap("BigReactors-Reactor_0")
  4. m = peripheral.wrap("monitor_0")
  5. t = peripheral.wrap("BigReactors-Turbine_0")
  6. t1 = peripheral.wrap("BigReactors-Turbine_1")
  7. local turnOnAt = 75
  8. local turnOffAt = 90
  9.  
  10. local energy = 0
  11. local energyStored = 0
  12. local energyMax = 0
  13. local energyStoredPercent = 0
  14. local RFProduction = 0
  15. local fuelUse = 0
  16. local coreTemp = 0
  17. local energy1 = 0
  18. local energyStored1 = 0
  19. local energyMax1 = 0
  20. local energyStoredPercent1 = 0
  21. local RFProduction1 = 0
  22. local fuelUse1 = 0
  23. local coreTemp1 = 0
  24. local timerCode
  25. local reactorOnline = true
  26. local turbinaOnline = false
  27.  
  28.  
  29. function online()
  30.    r.setActive(true)
  31.    --button.flash("Online")
  32. end
  33.  
  34. function offline()
  35.    r.setActive(false)
  36.    --button.flash("Offline")
  37. end
  38.  
  39. function comma_value(amount)
  40.    local formatted = amount
  41.    local swap = false
  42.    if formatted < 0 then
  43.       formatted = formatted*-1
  44.       swap = true
  45.    end
  46.    while true do
  47.       formatted, k = string.gsub(formatted, "^(%d+)(%d%d%d)", '%1,%2')
  48.       if k == 0 then
  49.          break
  50.       end
  51.    end
  52.    if swap then
  53.      formatted = "-"..formatted
  54.    end
  55.    return formatted
  56. end
  57.  
  58. function displayEn()
  59.    m.clear()
  60.    m.setCursorPos(1,1)
  61.    --print("Energy Use: "..energy)
  62.    m.write("Energie v T: ")
  63.    if energy < 0 then
  64.       m.setTextColor(colors.red)
  65.    else
  66.       m.setTextColor(colors.green)
  67.    end
  68.    m.write(comma_value(math.floor(energy)).. "RF/t")
  69.    m.setTextColor(colors.white)
  70.    m.setCursorPos(1,2)
  71.    m.write("Rotor speed: "..rotorspeed.."RPM")
  72.    m.setCursorPos(1,3)
  73.    m.write("Turbina je: ")
  74.    if turbinaOnline then
  75.         m.setTextColor(colors.green)
  76.         m.write("Online")
  77.    else
  78.     m.setTextColor(colors.red)
  79.         m.write("Offline")
  80.    end
  81.    m.setTextColor(colors.white)
  82.  
  83.    m.setCursorPos(1,5)
  84.    --print("Energy Use: "..energy1)
  85.    m.write("Energie v T1: ")
  86.    if energy1 < 0 then
  87.       m.setTextColor(colors.red)
  88.    else
  89.       m.setTextColor(colors.green)
  90.    end
  91.    m.write(comma_value(math.floor(energy1)).. "RF/t")
  92.    m.setTextColor(colors.white)
  93.    m.setCursorPos(1,6)
  94.    m.write("Rotor speed: "..rotorspeed1.."RPM")
  95.    m.setCursorPos(1,7)
  96.    m.write("Turbina1 je: ")
  97.    if turbinaOnline1 then
  98.         m.setTextColor(colors.green)
  99.         m.write("Online")
  100.    else
  101.     m.setTextColor(colors.red)
  102.         m.write("Offline")
  103.    end
  104.  
  105.    m.setTextColor(colors.white)
  106.    m.setCursorPos(1,9)
  107.    m.write("Reaktor je: ")
  108.    if reactorOnline then
  109.    m.setTextColor(colors.green)
  110.    m.write("Online")
  111.    else
  112.    m.setTextColor(colors.red)
  113.    m.write("Offline")
  114.    end
  115.    m.setTextColor(colors.white)
  116.    m.setCursorPos(1,10)
  117.    m.write("Voda v R: "..reactorVoda.." mB")
  118.    m.setTextColor(colors.white)
  119.    m.setCursorPos(1,11)
  120.    m.write("Para v R: "..reactorPara.." mB")
  121.  
  122.    m.setTextColor(colors.white)
  123.    m.setCursorPos(23,1)
  124.    m.write("RF/Tik: ")
  125.    m.setTextColor(colors.green)
  126.    m.write(comma_value(math.floor(RFProduction)).."RF/T")
  127.    m.setTextColor(colors.white)
  128.    m.setCursorPos(23,2)
  129.    m.write("Voda ven: "..math.floor(coreTemp).." mB")
  130.    m.setCursorPos(23,3)
  131.    m.write("Fuel Use: "..fuelUse.." MB/t")
  132.  
  133.    m.setTextColor(colors.white)
  134.    m.setCursorPos(23,5)
  135.    m.write("RF/Tik: ")
  136.    m.setTextColor(colors.green)
  137.    m.write(comma_value(math.floor(RFProduction1)).."RF/T")
  138.    m.setTextColor(colors.white)
  139.    m.setCursorPos(23,6)
  140.    m.write("Voda ven: "..math.floor(coreTemp1).." mB")
  141.    m.setCursorPos(23,7)
  142.    m.write("Fuel Use: "..fuelUse1.." MB/t")
  143. end
  144.  
  145. function checkEn()
  146.    local tempEnergy = 0
  147.    energyStored = t.getEnergyStored()
  148.    energyMax = t.getFluidAmountMax()
  149.    rotorspeed = math.floor(t.getRotorSpeed())
  150.    RFProduction = t.getEnergyProducedLastTick()
  151.    fuelUse = t.getInputAmount()
  152.    coreTemp = t.getOutputAmount()
  153.    turbinaOnline = t.getActive()
  154.    tempEnergy = t.getEnergyStored()
  155. -- t1
  156.    local tempEnergy1 = 0
  157.    energyStored1 = t1.getEnergyStored()
  158.    energyMax1 = t1.getFluidAmountMax()
  159.    rotorspeed1 = math.floor(t1.getRotorSpeed())
  160.    RFProduction1 = t1.getEnergyProducedLastTick()
  161.    fuelUse1 = t1.getInputAmount()
  162.    coreTemp1 = t1.getOutputAmount()
  163.    turbinaOnline1 = t1.getActive()
  164.    tempEnergy1 = t1.getEnergyStored()
  165. -- t1konec
  166.    sleep(0.1)
  167.    energy = t.getEnergyStored()
  168.    energy1 = t1.getEnergyStored()
  169.    reactorVoda = r.getCoolantAmount()
  170.    reactorPara = r.getHotFluidAmount()
  171. end
  172.  
  173.  
  174. function displayScreen()
  175.  --  repeat
  176.       checkEn()
  177.       displayEn()
  178. end
  179.  
  180. while true do
  181.    displayScreen()
  182.    sleep(1)
  183. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement