Advertisement
KaychenHH

reactor_double

Mar 27th, 2022
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.49 KB | None | 0 0
  1. monitor1 = peripheral.wrap("top")
  2. monitor2 = peripheral.wrap("monitor_0")
  3. --monitor3 = peripheral.wrap("monitor_34")
  4. react1 = peripheral.wrap("BigReactors_Reactor_0")
  5. react2 = peripheral.wrap("BigReactors_Reactor_1")
  6.  
  7. print(react1, react2)
  8. print(react1.getConnected, react2.getConnected)
  9.  
  10. react1.setActive(true)
  11. print("R1:", react1.isActive)
  12. react2.setActive(false)
  13. print("R2:", react2.isActive)
  14.  
  15. ron1 = true
  16. ron2 = false
  17. rrod1 = 97
  18. rrod2 = 90
  19.  
  20. react1.setAllControlRodLevels(rrod1)
  21. react2.setAllControlRodLevels(rrod2)
  22.  
  23. function MonAufbau(moni)
  24.  
  25.     moni.setTextScale(0.5)
  26.     moni.setBackgroundColor(colors.black)
  27.     moni.clear()
  28.     moni.setCursorPos(4,1)
  29.     moni.setBackgroundColor(colors.blue)
  30.     moni.setTextColor(colors.orange)
  31.     moni.write(" *** WuffelPower Control *** ")
  32.     moni.setBackgroundColor(colors.black)
  33.     moni.setTextColor(colors.blue)
  34.     moni.setCursorPos(1,3)
  35.     moni.write("Reactor1")
  36.     moni.setCursorPos(19,3)
  37.     moni.write("Reactor2")
  38.     moni.setCursorPos(10,3)
  39.     if ron1 == true then
  40.         moni.setTextColor(colors.green)
  41.         moni.write("online")
  42.     else
  43.         moni.setTextColor(colors.red)
  44.         moni.write("offline")
  45.     end
  46.     moni.setCursorPos(28,3)
  47.     if ron2 == true then
  48.         moni.setTextColor(colors.green)
  49.         moni.write("online")
  50.     else
  51.         moni.setTextColor(colors.red)
  52.         moni.write("offline")
  53.     end
  54.  
  55.     moni.setBackgroundColor(colors.lime)
  56.     moni.setTextColor(colors.white)
  57.     moni.setCursorPos(4,4)
  58.     moni.write(" ON  ")
  59.     moni.setCursorPos(22,4)
  60.     moni.write(" ON  ")
  61.     moni.setBackgroundColor(colors.red)
  62.     moni.setCursorPos(10,4)
  63.     moni.write(" OFF ")
  64.     moni.setCursorPos(28,4)
  65.     moni.write(" OFF ")
  66.  
  67.     moni.setBackgroundColor(colors.black)
  68.     moni.setTextColor(colors.blue)
  69.     moni.setCursorPos(1,6)
  70.     moni.write("ControlRods:    %")
  71.     moni.setCursorPos(19,6)
  72.     moni.write("ControlRods:    %")
  73.     moni.setCursorPos(14,6)
  74.     moni.write(string.format("%3d",rrod1))
  75.     moni.setCursorPos(32,6)
  76.     moni.write(string.format("%3d",rrod2))
  77.  
  78.     moni.setBackgroundColor(colors.lightGray)
  79.     moni.setTextColor(colors.orange)
  80.     moni.setCursorPos(2,7)
  81.     moni.write(" 0 ")
  82.     moni.setCursorPos(7,7)
  83.     moni.write(" 50 ")
  84.     moni.setCursorPos(13,7)
  85.     moni.write(" 100 ")
  86.     moni.setCursorPos(20,7)
  87.     moni.write(" 0 ")
  88.     moni.setCursorPos(25,7)
  89.     moni.write(" 50 ")
  90.     moni.setCursorPos(31 ,7)
  91.     moni.write(" 100 ")
  92.  
  93.     moni.setBackgroundColor(colors.blue)
  94.     moni.setCursorPos(2,8)
  95.     moni.write("-10")
  96.     moni.setCursorPos(6,8)
  97.     moni.write(" -1")
  98.     moni.setCursorPos(11,8)
  99.     moni.write(" +1")
  100.     moni.setCursorPos(15,8)
  101.     moni.write("+10")
  102.     moni.setCursorPos(20,8)
  103.     moni.write("-10")
  104.     moni.setCursorPos(24,8)
  105.     moni.write(" -1")
  106.     moni.setCursorPos(29,8)
  107.     moni.write(" +1")
  108.     moni.setCursorPos(33,8)
  109.     moni.write("+10")
  110.  
  111. end
  112.  
  113.  
  114. function ChangeRT(chNr, chVal)
  115.  
  116.     if chNr == 1 then
  117.         rrod1 = chVal
  118.         react1.setAllControlRodLevels(rrod1)
  119.     else
  120.         rrod2 = chVal
  121.         react2.setAllControlRodLevels(rrod2)
  122.     end
  123.  
  124. end
  125.  
  126. function ChangeR(chNr, chVal)
  127.  
  128.     if chNr == 1 then
  129.         rrod1 = rrod1 + chVal
  130.         react1.setAllControlRodLevels(rrod1)
  131.     else
  132.         rrod2 = rrod2 + chVal
  133.         react2.setAllControlRodLevels(rrod2)
  134.     end
  135.  
  136. end
  137.  
  138.  
  139.  
  140. MonAufbau(monitor1)
  141. MonAufbau(monitor2)
  142. -- MonAufbau(monitor3)
  143.  
  144. while true do
  145.     event, button, x, y = os.pullEvent()
  146.  
  147.     if event == "terminate" then
  148.         break
  149.     elseif event == "monitor_touch" then
  150.         if (button == "top") or (button == "monitor_0") or (button == "monitor_34") then
  151.         if y == 4 then
  152.             if (x > 3) and (x < 9) then
  153.                 ron1=true
  154.                 react1.setActive(ron1)
  155.             elseif (x > 9) and (x < 15) then
  156.                 ron1=false
  157.                 react1.setActive(ron1)
  158.             elseif (x > 21) and (x < 27) then
  159.                 ron2=true
  160.                 react2.setActive(ron2)
  161.             elseif (x > 27) and (x < 33) then
  162.                 ron2=false
  163.                 react2.setActive(ron2)
  164.             end
  165.         elseif y == 7 then
  166.             if (x > 1) and (x < 5) then
  167.                 ChangeRT(1,0)
  168.             elseif (x > 6) and (x < 11) then
  169.                 ChangeRT(1,50)
  170.             elseif (x > 12) and (x < 18) then
  171.                 ChangeRT(1,100)
  172.             elseif (x > 19) and (x < 23) then
  173.                 ChangeRT(2,0)
  174.             elseif (x > 24) and (x < 29) then
  175.                 ChangeRT(2,50)
  176.             elseif (x > 30) and (x < 36) then
  177.                 ChangeRT(2,100)
  178.             end
  179.         elseif y == 8 then
  180.             if (x > 1) and (x < 5) then
  181.                 ChangeR(1,-10)
  182.             elseif (x > 5) and (x < 9) then
  183.                 ChangeR(1,-1)
  184.             elseif (x > 10) and (x < 14) then
  185.                 ChangeR(1,1)
  186.             elseif (x > 14) and (x < 18) then
  187.                 ChangeR(1,10)
  188.             elseif (x > 19) and (x < 23) then
  189.                 ChangeR(2,-10)
  190.             elseif (x > 23) and (x < 27) then
  191.                 ChangeR(2,-1)
  192.             elseif (x > 28) and (x < 32) then
  193.                 ChangeR(2,1)
  194.             elseif (x > 32) and (x < 36) then
  195.                 ChangeR(2,10)
  196.             end
  197.         end
  198.         MonAufbau(monitor1)
  199.         MonAufbau(monitor2)
  200.         -- MonAufbau(monitor3)
  201.         end
  202.     else
  203.         print(event, button, x, y)
  204.     end
  205.  
  206.  
  207. end
  208.  
  209.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement