Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.23 KB | None | 0 0
  1. mon = peripheral.wrap("left")
  2. r1 = peripheral.wrap("BigReactors-Reactor_2")
  3. r2 = peripheral.wrap("BigReactors-Reactor_3")
  4. mod = 1
  5. x = 0
  6. y = 0
  7. r1min = 2000000
  8. r1max = 7000000
  9. r1minarl = 50
  10. r1maxarl = 90
  11. r2min = 2000000
  12. r2max = 7000000
  13. r2minarl = 0
  14. r2maxarl = 100
  15. automata1 = 0
  16. automata2 = 0
  17. automata3 = 0
  18. function click()
  19.     event, pos, x, y = os.pullEvent("monitor_touch")
  20. end
  21.  
  22. function drawLine(x,y,l,s,c)
  23.     for yPos = y, y+l-1 do
  24.         mon.setBackgroundColor(c)
  25.         mon.setCursorPos(x, yPos)
  26.         mon.write(string.rep(" ", s))
  27.     end
  28.     mon.setBackgroundColor(colors.black)
  29. end
  30.  
  31. function futas()
  32.     mon.setTextScale(0.8)
  33.     mon.setBackgroundColor(colors.black)
  34.     mon.clear()
  35.    
  36.     if x > 2 and x < 18 and y > 2 and y < 6 then
  37.         mod = 1
  38.     elseif x > 2 and x < 18 and y > 6 and y < 10 then
  39.         mod = 2
  40.     elseif x > 2 and x < 18 and y > 10 and y < 14 then
  41.         mod = 3
  42.     end
  43.    
  44.     if mod == 1 and x > 59 and x < 71 and y > 2 and y < 6 then
  45.         r1.setActive(true)
  46.         x=0
  47.         y=0
  48.     elseif mod == 1 and x > 71 and x < 83 and y > 2 and y < 6 then
  49.         r1.setActive(false)
  50.         x=0
  51.         y=0
  52.     elseif mod == 1 and x > 71 and x < 83 and y > 6 and y < 10 then
  53.         if automata1 == 0 then
  54.             automata1 = 1
  55.         else
  56.             automata1 = 0
  57.         end
  58.         x=0
  59.         y=0
  60.     end
  61.    
  62.     if mod == 1 then
  63.         mon.setCursorPos(3,3)
  64.         mon.setBackgroundColor(colors.lightBlue)
  65.         mon.write("              ")
  66.         mon.setCursorPos(3,4)
  67.         mon.write(" 1-es reaktor ")
  68.         mon.setCursorPos(3,5)
  69.         mon.write("              ")
  70.         mon.setBackgroundColor(colors.blue)
  71.         mon.setCursorPos(3,7)
  72.         mon.write("              ")
  73.         mon.setCursorPos(3,8)
  74.         mon.write(" 2-es reaktor ")
  75.         mon.setCursorPos(3,9)
  76.         mon.write("              ")
  77.         mon.setBackgroundColor(colors.blue)
  78.         mon.setCursorPos(3,11)
  79.         mon.write("              ")
  80.         mon.setCursorPos(3,12)
  81.         mon.write(" 3-es reaktor ")
  82.         mon.setCursorPos(3,13)
  83.         mon.write("              ")
  84.         mon.setBackgroundColor(colors.black)
  85.         mon.setCursorPos(25,4)
  86.         mon.write("Allapot: ")
  87.         mon.setCursorPos(36,4)
  88.         if r1.getActive() == true then
  89.             mon.setTextColor(colors.green)
  90.             mon.write("Aktiv")
  91.             mon.setTextColor(colors.white)
  92.             mon.setBackgroundColor(colors.green)
  93.             mon.setCursorPos(60,3)
  94.             mon.write("          ")
  95.             mon.setCursorPos(60,4)
  96.             mon.write("    ON    ")
  97.             mon.setCursorPos(60,5)
  98.             mon.write("          ")
  99.             mon.setBackgroundColor(colors.red)
  100.             mon.setCursorPos(72,3)
  101.             mon.write("          ")
  102.             mon.setCursorPos(72,4)
  103.             mon.write("    OFF   ")
  104.             mon.setCursorPos(72,5)
  105.             mon.write("          ")
  106.             mon.setBackgroundColor(colors.black)
  107.         else
  108.             mon.setTextColor(colors.red)
  109.             mon.write("Inaktiv")
  110.             mon.setTextColor(colors.white)
  111.             mon.setBackgroundColor(colors.lime)
  112.             mon.setCursorPos(60,3)
  113.             mon.write("          ")
  114.             mon.setCursorPos(60,4)
  115.             mon.write("    ON    ")
  116.             mon.setCursorPos(60,5)
  117.             mon.write("          ")
  118.             mon.setBackgroundColor(colors.pink)
  119.             mon.setCursorPos(72,3)
  120.             mon.write("          ")
  121.             mon.setCursorPos(72,4)
  122.             mon.write("    OFF   ")
  123.             mon.setCursorPos(72,5)
  124.             mon.write("          ")
  125.             mon.setBackgroundColor(colors.black)
  126.         end
  127.         mon.setCursorPos(72,7)
  128.         mon.setBackgroundColor(colors.blue)
  129.         mon.write("          ")
  130.         mon.setCursorPos(72,9)
  131.         mon.setCursorPos(72,8)
  132.         if automata1 == 0 then
  133.             mon.write(" AUTOMATA ")
  134.         elseif automata1 == 1 then
  135.             mon.write("  MANUAL  ")
  136.         end
  137.         mon.setBackgroundColor(colors.black)
  138.         mon.setCursorPos(25,5)
  139.         mon.write("Yellorium:")
  140.         mon.setCursorPos(35,5)
  141.         if r1.getFuelAmount() < 35000 then
  142.             mon.setTextColor(colors.red)
  143.         else
  144.             mon.setTextColor(colors.green)
  145.         end
  146.         mon.write(" "..r1.getFuelAmount().." mB")
  147.         mon.setTextColor(colors.white)
  148.         mon.setCursorPos(25,7)
  149.         mon.write("Energia:")
  150.         mon.setCursorPos(25,9)
  151.         mon.write("Tarolt: "..(math.floor(r1.getEnergyStored()/10000)/100).." mRF")
  152.         mon.setCursorPos(25,10)
  153.         mon.write("Termelt: "..math.floor(r1.getEnergyProducedLastTick()).." RF/t")
  154.        
  155.         mon.setCursorPos(25,23)
  156.         mon.write("0. rod: ")
  157.         drawLine(27,25,10,2,colors.gray)
  158.         drawLine(27,25,math.floor(r1.getControlRodLevel(0)/10),2,colors.yellow)
  159.         mon.setCursorPos(26,37)
  160.         mon.write(r1.getControlRodLevel(0).." %")
  161.        
  162.         mon.setCursorPos(38,23)
  163.         mon.write("1. rod: ")
  164.         drawLine(40,25,10,2,colors.gray)
  165.         drawLine(40,25,math.floor(r1.getControlRodLevel(1)/10),2,colors.yellow)
  166.         mon.setCursorPos(39,37)
  167.         mon.write(r1.getControlRodLevel(1).." %")
  168.        
  169.         mon.setCursorPos(51,23)
  170.         mon.write("2. rod: ")
  171.         drawLine(53,25,10,2,colors.gray)
  172.         drawLine(53,25,math.floor(r1.getControlRodLevel(2)/10),2,colors.yellow)
  173.         mon.setCursorPos(52,37)
  174.         mon.write(r1.getControlRodLevel(2).." %")
  175.        
  176.         mon.setCursorPos(64,23)
  177.         mon.write("3. rod: ")
  178.         drawLine(66,25,10,2,colors.gray)
  179.         drawLine(66,25,math.floor(r1.getControlRodLevel(3)/10),2,colors.yellow)
  180.         mon.setCursorPos(65,37)
  181.         mon.write(r1.getControlRodLevel(3).." %")
  182.        
  183.         mon.setCursorPos(77,23)
  184.         mon.write("4. rod: ")
  185.         drawLine(79,25,10,2,colors.gray)
  186.         drawLine(79,25,math.floor(r1.getControlRodLevel(4)/10),2,colors.yellow)
  187.         mon.setCursorPos(78,37)
  188.         mon.write(r1.getControlRodLevel(4).." %")
  189.  
  190.         mon.setBackgroundColor(colors.black)
  191.        
  192.        
  193.        
  194.     elseif mod == 2 then
  195.         mon.setCursorPos(3,3)
  196.         mon.setBackgroundColor(colors.blue)
  197.         mon.write("              ")
  198.         mon.setCursorPos(3,4)
  199.         mon.write(" 1-es reaktor ")
  200.         mon.setCursorPos(3,5)
  201.         mon.write("              ")
  202.         mon.setBackgroundColor(colors.lightBlue)
  203.         mon.setCursorPos(3,7)
  204.         mon.write("              ")
  205.         mon.setCursorPos(3,8)
  206.         mon.write(" 2-es reaktor ")
  207.         mon.setCursorPos(3,9)
  208.         mon.write("              ")
  209.         mon.setBackgroundColor(colors.blue)
  210.         mon.setCursorPos(3,11)
  211.         mon.write("              ")
  212.         mon.setCursorPos(3,12)
  213.         mon.write(" 3-es reaktor ")
  214.         mon.setCursorPos(3,13)
  215.         mon.write("              ")
  216.         mon.setBackgroundColor(colors.black)
  217.         mon.setCursorPos(25,4)
  218.         mon.write("Allapot: ")
  219.         mon.setCursorPos(36,4)
  220.         if r2.getActive() == true then
  221.             mon.setTextColor(colors.green)
  222.             mon.write("Aktiv")
  223.             mon.setTextColor(colors.white)
  224.         else
  225.             mon.setTextColor(colors.red)
  226.             mon.write("Inaktiv")
  227.             mon.setTextColor(colors.white)
  228.         end
  229.         mon.setCursorPos(25,5)
  230.         mon.write("Yellorium:")
  231.         mon.setCursorPos(35,5)
  232.         if r2.getFuelAmount() < 35000 then
  233.             mon.setTextColor(colors.red)
  234.         else
  235.             mon.setTextColor(colors.green)
  236.         end
  237.         mon.write(" "..r2.getFuelAmount().." mB")
  238.         mon.setTextColor(colors.white)
  239.         mon.setCursorPos(25,7)
  240.         mon.write("Energia:")
  241.         mon.setCursorPos(25,9)
  242.         mon.write("Tarolt: "..(math.floor(r2.getEnergyStored()/10000)/100).." mRF")
  243.         mon.setCursorPos(25,10)
  244.         mon.write("Termelt: "..math.floor(r2.getEnergyProducedLastTick()).." RF/t")
  245.         mon.setCursorPos(25,12)
  246.         mon.write("Control rodok: "..r2.getControlRodLevel(0).." %")
  247.     end
  248.    
  249.     if automata == 0 then
  250.         if r1.getEnergyStored() >= r1max then
  251.             r1.setAllControlRodLevels(r1maxarl)
  252.         elseif r1.getEnergyStored() <= r1min then
  253.             r1.setAllControlRodLevels(r1minarl)
  254.         end
  255.         if r2.getEnergyStored() >= r2max then
  256.             r2.setAllControlRodLevels(r2maxarl)
  257.         elseif r2.getEnergyStored() <= r2min then
  258.             r2.setAllControlRodLevels(r2minarl)
  259.         end
  260.     else
  261.    
  262.     end
  263.     term.clear()
  264.     term.setCursorPos(1,1)
  265.     print(mod)
  266.     sleep(1)
  267. end
  268.  
  269. while true do
  270.     parallel.waitForAny(click,futas)
  271. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement