Advertisement
Bendresz

Untitled

Nov 20th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.75 KB | None | 0 0
  1. mon = peripheral.wrap("left")
  2. r1 = peripheral.wrap("BigReactors-Reactor_2")
  3. r2 = peripheral.wrap("BigReactors-Reactor_3")
  4. r3 = peripheral.wrap("BigReactors-Reactor_4")
  5. mod = 1
  6. x = 0
  7. y = 0
  8. r1mod = 0
  9. r1min = 2000000
  10. r1max = 7000000
  11. r1minarl = 50
  12. r1maxarl = 90
  13. r1ossz = 50
  14. r2mod = 0
  15. r2min = 2000000
  16. r2max = 7000000
  17. r2minarl = 50
  18. r2maxarl = 90
  19. r2ossz = 50
  20. automata1 = 0
  21. automata2 = 0
  22. function click()
  23.     event, pos, x, y = os.pullEvent("monitor_touch")
  24. end
  25.  
  26. function drawLine(x,y,l,s,c)
  27.     for yPos = y, y+l-1 do
  28.         mon.setBackgroundColor(c)
  29.         mon.setCursorPos(x, yPos)
  30.         mon.write(string.rep(" ", s))
  31.     end
  32.     mon.setBackgroundColor(colors.black)
  33. end
  34.  
  35. function futas()
  36.     mon.setTextScale(0.8)
  37.     mon.setBackgroundColor(colors.black)
  38.     mon.clear()
  39.    
  40.     if x > 2 and x < 18 and y > 2 and y < 6 then
  41.         mod = 1
  42.     elseif x > 2 and x < 18 and y > 6 and y < 10 then
  43.         mod = 2
  44.     elseif x > 2 and x < 18 and y > 10 and y < 14 then
  45.         mod = 3
  46.     end
  47.    
  48.     if mod == 1 then
  49.         if  x > 59 and x < 71 and y > 2 and y < 6 then
  50.             r1.setActive(true)
  51.             x=0
  52.             y=0
  53.         elseif x > 71 and x < 83 and y > 2 and y < 6 then
  54.             r1.setActive(false)
  55.             x=0
  56.             y=0
  57.         elseif x > 71 and x < 83 and y > 6 and y < 10 then
  58.             if automata1 == 0 then
  59.                 automata1 = 1
  60.             else
  61.                 automata1 = 0
  62.             end
  63.             x=0
  64.             y=0
  65.         end
  66.         if automata1 == 0 then
  67.             if  r1min < r1max and x > 24 and x < 43 and y > 13 and y < 15 then
  68.                 r1min = r1min + 1000000
  69.                 x=0
  70.                 y=0
  71.             elseif r1min > 0 and x > 24 and x < 43 and y > 15 and y < 17 then
  72.                 r1min = r1min - 1000000
  73.                 x=0
  74.                 y=0
  75.             elseif and r1max < 10000000 and x > 59 and x < 78 and y > 13 and y < 15 then
  76.                 r1max = r1max + 1000000
  77.                 x=0
  78.                 y=0
  79.             elseif and r1max > r1min and x > 59 and x < 78 and y > 15 and y < 17 then
  80.                 r1max = r1max - 1000000
  81.                 x=0
  82.                 y=0
  83.                
  84.             elseif r1minarl < r1maxarl and x > 24 and x < 43 and y > 18 and y < 20 then
  85.                 r1minarl = r1minarl + 10
  86.                 x=0
  87.                 y=0
  88.             elseif r1minarl > 0 and x > 24 and x < 43 and y > 19 and y < 21 then
  89.                 r1minarl = r1minarl - 10
  90.                 x=0
  91.                 y=0
  92.             elseif r1maxarl < 100 and x > 59 and x < 78 and y > 18 and y < 20 then
  93.                 r1maxarl = r1maxarl + 10
  94.                 x=0
  95.                 y=0
  96.             elseif r1maxarl > r1minarl and x > 59 and x < 78 and y > 19 and y < 21 then
  97.                 r1maxarl = r1maxarl - 10
  98.                 x=0
  99.                 y=0
  100.         else
  101.             if  x > 59 and x < 71 and y > 6 and y < 10 then
  102.                 if r1mod == 0 then
  103.                     r1mod = 1
  104.                     x = 0
  105.                     y = 0
  106.                 else
  107.                     r1mod = 0
  108.                     x = 0
  109.                     y = 0
  110.                 end
  111.             end
  112.             if r1mod == 0 then
  113.                 if r1ossz > 0 and x > 59 and x < 63 and y > 10 and y < 14 then
  114.                     r1ossz = r1ossz - 10
  115.                     x = 0
  116.                     y = 0
  117.                 elseif r1ossz < 100 and x > 66 and x < 71 and y > 10 and y < 14 then
  118.                     r1ossz = r1ossz + 10
  119.                     x = 0
  120.                     y = 0
  121.                 end
  122.             else
  123.            
  124.             end
  125.         end
  126.            
  127.     elseif mod == 2 then
  128.         elseif x > 59 and x < 71 and y > 2 and y < 6 then
  129.             r2.setActive(true)
  130.             x=0
  131.             y=0
  132.         elseif x > 71 and x < 83 and y > 2 and y < 6 then
  133.             r2.setActive(false)
  134.             x=0
  135.             y=0
  136.         elseif x > 71 and x < 83 and y > 6 and y < 10 then
  137.             if automata2 == 0 then
  138.                 automata2 = 1
  139.             else
  140.                 automata2 = 0
  141.             end
  142.             x=0
  143.             y=0
  144.  
  145.     elseif mod == 3 then
  146.    
  147.     end
  148.    
  149.     if mod == 1 then
  150.         mon.setCursorPos(3,3)
  151.         mon.setBackgroundColor(colors.lightBlue)
  152.         mon.write("              ")
  153.         mon.setCursorPos(3,4)
  154.         mon.write(" 1-es reaktor ")
  155.         mon.setCursorPos(3,5)
  156.         mon.write("              ")
  157.         mon.setBackgroundColor(colors.blue)
  158.         mon.setCursorPos(3,7)
  159.         mon.write("              ")
  160.         mon.setCursorPos(3,8)
  161.         mon.write(" 2-es reaktor ")
  162.         mon.setCursorPos(3,9)
  163.         mon.write("              ")
  164.         mon.setBackgroundColor(colors.blue)
  165.         mon.setCursorPos(3,11)
  166.         mon.write("              ")
  167.         mon.setCursorPos(3,12)
  168.         mon.write(" 3-es reaktor ")
  169.         mon.setCursorPos(3,13)
  170.         mon.write("              ")
  171.         mon.setBackgroundColor(colors.black)
  172.         mon.setCursorPos(25,4)
  173.         mon.write("Allapot: ")
  174.         mon.setCursorPos(36,4)
  175.         if r1.getActive() == true then
  176.             mon.setTextColor(colors.green)
  177.             mon.write("Aktiv")
  178.             mon.setTextColor(colors.white)
  179.             mon.setBackgroundColor(colors.green)
  180.             mon.setCursorPos(60,3)
  181.             mon.write("          ")
  182.             mon.setCursorPos(60,4)
  183.             mon.write("    ON    ")
  184.             mon.setCursorPos(60,5)
  185.             mon.write("          ")
  186.             mon.setBackgroundColor(colors.red)
  187.             mon.setCursorPos(72,3)
  188.             mon.write("          ")
  189.             mon.setCursorPos(72,4)
  190.             mon.write("    OFF   ")
  191.             mon.setCursorPos(72,5)
  192.             mon.write("          ")
  193.             mon.setBackgroundColor(colors.black)
  194.         else
  195.             mon.setTextColor(colors.red)
  196.             mon.write("Inaktiv")
  197.             mon.setTextColor(colors.white)
  198.             mon.setBackgroundColor(colors.lime)
  199.             mon.setCursorPos(60,3)
  200.             mon.write("          ")
  201.             mon.setCursorPos(60,4)
  202.             mon.write("    ON    ")
  203.             mon.setCursorPos(60,5)
  204.             mon.write("          ")
  205.             mon.setBackgroundColor(colors.pink)
  206.             mon.setCursorPos(72,3)
  207.             mon.write("          ")
  208.             mon.setCursorPos(72,4)
  209.             mon.write("    OFF   ")
  210.             mon.setCursorPos(72,5)
  211.             mon.write("          ")
  212.             mon.setBackgroundColor(colors.black)
  213.         end
  214.        
  215.         if automata1 == 0 then
  216.             mon.setCursorPos(25,14)
  217.             mon.setBackgroundColor(colors.blue)
  218.             mon.write("        +++        ")
  219.             mon.setCursorPos(25,16)
  220.             mon.write("        ---        ")
  221.             mon.setBackgroundColor(colors.black)
  222.             mon.setCursorPos(25,15)
  223.             mon.write("Energia min: "..math.floor(r1min/1000000).." mRF")
  224.            
  225.             mon.setCursorPos(25,18)
  226.             mon.setBackgroundColor(colors.blue)
  227.             mon.write("        +++        ")
  228.             mon.setCursorPos(25,20)
  229.             mon.write("        ---        ")
  230.             mon.setBackgroundColor(colors.black)
  231.             mon.setCursorPos(25,19)
  232.             mon.write("Rodok szintje: "..r1minarl.."%")
  233.            
  234.             mon.setCursorPos(60,14)
  235.             mon.setBackgroundColor(colors.blue)
  236.             mon.write("        +++        ")
  237.             mon.setCursorPos(60,16)
  238.             mon.write("        ---        ")
  239.             mon.setBackgroundColor(colors.black)
  240.             mon.setCursorPos(60,15)
  241.             mon.write("Energia max: "..math.floor(r1max/1000000).." mRF")
  242.            
  243.             mon.setCursorPos(60,18)
  244.             mon.setBackgroundColor(colors.blue)
  245.             mon.write("        +++        ")
  246.             mon.setCursorPos(60,20)
  247.             mon.write("        ---        ")
  248.             mon.setBackgroundColor(colors.black)
  249.             mon.setCursorPos(60,19)
  250.             mon.write("Rodok szintje: "..r1maxarl.."%")
  251.         else
  252.             mon.setCursorPos(60,7)
  253.             mon.setBackgroundColor(colors.blue)
  254.             mon.write("          ")
  255.             mon.setCursorPos(60,9)
  256.             mon.write("          ")
  257.             mon.setCursorPos(60,8)
  258.             if r1mod == 0 then
  259.                 mon.write("  OSSZES  ")
  260.                 mon.setCursorPos(60,11)
  261.                 mon.write("   ")
  262.                 mon.setCursorPos(60,13)
  263.                 mon.write("   ")
  264.                 mon.setCursorPos(60,14)
  265.                 mon.write(" - ")
  266.                 mon.setCursorPos(67,11)
  267.                 mon.write("   ")
  268.                 mon.setCursorPos(67,13)
  269.                 mon.write("   ")
  270.                 mon.setCursorPos(67,14)
  271.                 mon.write(" + ")
  272.                 mon.setBackgroundColor(color.black)
  273.                 mon.setCursorPos(64,14)
  274.                 mon.write(r1ossz.."%")
  275.                 r1.setAllControlRodLevels(r1ossz)
  276.             else
  277.                 mon.write("  KULON   ")
  278.             end
  279.         end
  280.        
  281.         mon.setCursorPos(72,7)
  282.         mon.setBackgroundColor(colors.blue)
  283.         mon.write("          ")
  284.         mon.setCursorPos(72,9)
  285.         mon.write("          ")
  286.         mon.setCursorPos(72,8)
  287.         if automata1 == 0 then
  288.             mon.write(" AUTOMATA ")
  289.         elseif automata1 == 1 then
  290.             mon.write("  MANUAL  ")
  291.         end
  292.         mon.setBackgroundColor(colors.black)
  293.         mon.setCursorPos(25,5)
  294.         mon.write("Yellorium:")
  295.         mon.setCursorPos(35,5)
  296.         if r1.getFuelAmount() < 35000 then
  297.             mon.setTextColor(colors.red)
  298.         else
  299.             mon.setTextColor(colors.green)
  300.         end
  301.         mon.write(" "..r1.getFuelAmount().." mB")
  302.         mon.setTextColor(colors.white)
  303.         mon.setCursorPos(25,7)
  304.         mon.write("Energia:")
  305.         mon.setCursorPos(25,9)
  306.         mon.write("Tarolt: "..(math.floor(r1.getEnergyStored()/10000)/100).." mRF")
  307.         mon.setCursorPos(25,10)
  308.         mon.write("Termelt: "..math.floor(r1.getEnergyProducedLastTick()).." RF/t")
  309.        
  310.         mon.setCursorPos(25,23)
  311.         mon.write("0. rod: ")
  312.         drawLine(27,25,10,2,colors.gray)
  313.         drawLine(27,25,math.floor(r1.getControlRodLevel(0)/10),2,colors.yellow)
  314.         mon.setCursorPos(26,37)
  315.         mon.write(r1.getControlRodLevel(0).." %")
  316.        
  317.         mon.setCursorPos(38,23)
  318.         mon.write("1. rod: ")
  319.         drawLine(40,25,10,2,colors.gray)
  320.         drawLine(40,25,math.floor(r1.getControlRodLevel(1)/10),2,colors.yellow)
  321.         mon.setCursorPos(39,37)
  322.         mon.write(r1.getControlRodLevel(1).." %")
  323.        
  324.         mon.setCursorPos(51,23)
  325.         mon.write("2. rod: ")
  326.         drawLine(53,25,10,2,colors.gray)
  327.         drawLine(53,25,math.floor(r1.getControlRodLevel(2)/10),2,colors.yellow)
  328.         mon.setCursorPos(52,37)
  329.         mon.write(r1.getControlRodLevel(2).." %")
  330.        
  331.         mon.setCursorPos(64,23)
  332.         mon.write("3. rod: ")
  333.         drawLine(66,25,10,2,colors.gray)
  334.         drawLine(66,25,math.floor(r1.getControlRodLevel(3)/10),2,colors.yellow)
  335.         mon.setCursorPos(65,37)
  336.         mon.write(r1.getControlRodLevel(3).." %")
  337.        
  338.         mon.setCursorPos(77,23)
  339.         mon.write("4. rod: ")
  340.         drawLine(79,25,10,2,colors.gray)
  341.         drawLine(79,25,math.floor(r1.getControlRodLevel(4)/10),2,colors.yellow)
  342.         mon.setCursorPos(78,37)
  343.         mon.write(r1.getControlRodLevel(4).." %")
  344.  
  345.         mon.setBackgroundColor(colors.black)
  346.        
  347.        
  348.        
  349.     elseif mod == 2 then
  350.         mon.setCursorPos(3,3)
  351.         mon.setBackgroundColor(colors.blue)
  352.         mon.write("              ")
  353.         mon.setCursorPos(3,4)
  354.         mon.write(" 1-es reaktor ")
  355.         mon.setCursorPos(3,5)
  356.         mon.write("              ")
  357.         mon.setBackgroundColor(colors.lightBlue)
  358.         mon.setCursorPos(3,7)
  359.         mon.write("              ")
  360.         mon.setCursorPos(3,8)
  361.         mon.write(" 2-es reaktor ")
  362.         mon.setCursorPos(3,9)
  363.         mon.write("              ")
  364.         mon.setBackgroundColor(colors.blue)
  365.         mon.setCursorPos(3,11)
  366.         mon.write("              ")
  367.         mon.setCursorPos(3,12)
  368.         mon.write(" 3-es reaktor ")
  369.         mon.setCursorPos(3,13)
  370.         mon.write("              ")
  371.         mon.setBackgroundColor(colors.black)
  372.         mon.setCursorPos(25,4)
  373.         mon.write("Allapot: ")
  374.         mon.setCursorPos(36,4)
  375.         if r2.getActive() == true then
  376.             mon.setTextColor(colors.green)
  377.             mon.write("Aktiv")
  378.             mon.setTextColor(colors.white)
  379.         else
  380.             mon.setTextColor(colors.red)
  381.             mon.write("Inaktiv")
  382.             mon.setTextColor(colors.white)
  383.         end
  384.         mon.setCursorPos(25,5)
  385.         mon.write("Blutonium:")
  386.         mon.setCursorPos(35,5)
  387.         if r2.getFuelAmount() < 35000 then
  388.             mon.setTextColor(colors.red)
  389.         else
  390.             mon.setTextColor(colors.green)
  391.         end
  392.         mon.write(" "..r2.getFuelAmount().." mB")
  393.         mon.setTextColor(colors.white)
  394.         mon.setCursorPos(25,7)
  395.         mon.write("Energia:")
  396.         mon.setCursorPos(25,9)
  397.         mon.write("Tarolt: "..(math.floor(r2.getEnergyStored()/10000)/100).." mRF")
  398.         mon.setCursorPos(25,10)
  399.         mon.write("Termelt: "..math.floor(r2.getEnergyProducedLastTick()).." RF/t")
  400.         mon.setCursorPos(25,12)
  401.         mon.write("Control rodok: "..r2.getControlRodLevel(0).." %")
  402.        
  403.     elseif mod == 3 then
  404.         mon.setCursorPos(3,3)
  405.         mon.setBackgroundColor(colors.blue)
  406.         mon.write("              ")
  407.         mon.setCursorPos(3,4)
  408.         mon.write(" 1-es reaktor ")
  409.         mon.setCursorPos(3,5)
  410.         mon.write("              ")
  411.         mon.setBackgroundColor(colors.blue)
  412.         mon.setCursorPos(3,7)
  413.         mon.write("              ")
  414.         mon.setCursorPos(3,8)
  415.         mon.write(" 2-es reaktor ")
  416.         mon.setCursorPos(3,9)
  417.         mon.write("              ")
  418.         mon.setBackgroundColor(colors.lightBlue)
  419.         mon.setCursorPos(3,11)
  420.         mon.write("              ")
  421.         mon.setCursorPos(3,12)
  422.         mon.write(" 3-es reaktor ")
  423.         mon.setCursorPos(3,13)
  424.         mon.write("              ")
  425.         mon.setBackgroundColor(colors.black)
  426.         mon.setCursorPos(25,4)
  427.         mon.write("Allapot: ")
  428.         mon.setCursorPos(36,4)
  429.         if r3.getActive() == true then
  430.             mon.setTextColor(colors.green)
  431.             mon.write("Aktiv")
  432.             mon.setTextColor(colors.white)
  433.         else
  434.             mon.setTextColor(colors.red)
  435.             mon.write("Inaktiv")
  436.             mon.setTextColor(colors.white)
  437.         end
  438.         mon.setCursorPos(25,5)
  439.         mon.write("Yellorium:")
  440.         mon.setCursorPos(35,5)
  441.         if r3.getFuelAmount() < 35000 then
  442.             mon.setTextColor(colors.red)
  443.         else
  444.             mon.setTextColor(colors.green)
  445.         end
  446.         mon.write(" "..r3.getFuelAmount().." mB")
  447.         mon.setTextColor(colors.white)
  448.         mon.setCursorPos(25,7)
  449.         mon.write("Energia:")
  450.         mon.setCursorPos(25,9)
  451.         mon.write("Tarolt: "..(math.floor(r3.getEnergyStored()/10000)/100).." mRF")
  452.         mon.setCursorPos(25,10)
  453.         mon.write("Termelt: "..math.floor(r3.getEnergyProducedLastTick()).." RF/t")
  454.         mon.setCursorPos(25,12)
  455.         mon.write("Control rodok: "..r3.getControlRodLevel(0).." %")
  456.     end
  457.    
  458.     if automata1 == 0 then
  459.         if r1.getEnergyStored() >= r1max then
  460.             r1.setAllControlRodLevels(r1maxarl)
  461.         elseif r1.getEnergyStored() <= r1min then
  462.             r1.setAllControlRodLevels(r1minarl)
  463.         end
  464.     end
  465.     if automata2 == 0 then
  466.         if r2.getEnergyStored() >= r2max then
  467.             r2.setAllControlRodLevels(r2maxarl)
  468.         elseif r2.getEnergyStored() <= r2min then
  469.             r2.setAllControlRodLevels(r2minarl)
  470.         end
  471.     end
  472.     term.clear()
  473.     term.setCursorPos(1,1)
  474.     print(mod)
  475.     sleep(1)
  476. end
  477.  
  478. while true do
  479.     parallel.waitForAny(click,futas)
  480. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement