Advertisement
Kazadaoex

Reactor Touch Screen

Apr 24th, 2015
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local args = {...};
  2.  
  3. local screen = "monitor_16"
  4. local RsInSide = "right"
  5. local RsOutSide = "top"
  6.  
  7. local Nreactor1="BigReactors-Reactor_0"
  8. local Nreactor1 = "BigReactors-Reactor_0"
  9. local Nreactor2 = "BigReactors-Reactor_2"
  10. local Nreactor3 = "BigReactors-Reactor_3"
  11. local Nreactor4 = "BigReactors-Reactor_4"
  12. local Nreactor5 = "BigReactors-Reactor_5"
  13. local Nreactor6 = "BigReactors-Reactor_6"
  14. local Nreactor7 = "BigReactors-Reactor_7"
  15. local Nreactor8 = "BigReactors-Reactor_8"
  16.  
  17. local Nturbine1 = "BigReactors-Turbine_0"
  18. local Nturbine2 = "BigReactors-Turbine_1"
  19. local Nturbine3 = "BigReactors-Turbine_2"
  20. local Nturbine4 = "BigReactors-Turbine_3"
  21. local Nturbine5 = "BigReactors-Turbine_4"
  22. local Nturbine6 = "BigReactors-Turbine_5"
  23. local Nturbine7 = "BigReactors-Turbine_6"
  24. local Nturbine8 = "BigReactors-Turbine_7"
  25.  
  26.     rednet.open("back");
  27.     reactor1 = peripheral.wrap(Nreactor1);
  28.     reactor2 = peripheral.wrap(Nreactor2);
  29.     reactor3 = peripheral.wrap(Nreactor3);
  30.     reactor4 = peripheral.wrap(Nreactor4);
  31.     reactor5 = peripheral.wrap(Nreactor5);
  32.     reactor6 = peripheral.wrap(Nreactor6);
  33.     reactor7 = peripheral.wrap(Nreactor7);
  34.     reactor8 = peripheral.wrap(Nreactor8);
  35.  
  36.     turbine1 = peripheral.wrap(Nturbine1);
  37.     turbine2 = peripheral.wrap(Nturbine2);
  38.     turbine3 = peripheral.wrap(Nturbine3);
  39.     turbine4 = peripheral.wrap(Nturbine4);
  40.     turbine5 = peripheral.wrap(Nturbine5);
  41.     turbine6 = peripheral.wrap(Nturbine6);
  42.     turbine7 = peripheral.wrap(Nturbine7);
  43.     turbine8 = peripheral.wrap(Nturbine8);
  44.  
  45.     monitor = peripheral.wrap(screen);
  46.     monitor.setBackgroundColor( colors.black );
  47.     monitor.clear();
  48.  
  49. function UIprint( wd, x, y, text, color )
  50.     local a, b = wd.getCursorPos();
  51.     wd.setTextColor( color );
  52.     wd.setCursorPos( x, y );
  53.     wd.write(text);
  54.     monitor.setBackgroundColor( colors.black );
  55.     wd.setCursorPos( a, b );
  56. end
  57.  
  58. function UIHeader( wd, x, y, wx, wy, text, clr, txtclr )
  59.     local r = window.create( wd, x, y, wx, wy );
  60.     px = x + (wx / 2) - (math.floor(string.len(text) / 2));
  61.     py = y + math.floor(wy/2);
  62.         r.setBackgroundColor( clr );
  63.         r.clear();
  64.         UIprint(wd, px, py, text, txtclr );
  65. end
  66.  
  67. function UILaserButton( wd, xl, yl, wxl, wyl, text1, text2, clr1, clr2, txtclr1, txtclr2 )
  68.     local r = window.create( wd, xl, yl, wxl, wyl );
  69.     pxl = xl + (wxl / 2) - (math.floor(string.len(text1) / 2));
  70.     pyl = yl + 1
  71.     if redstone.getInput(RsInSide) then
  72.         r.setBackgroundColor( clr1 );
  73.         r.clear();
  74.         UIprint(wd, pxl, pyl, text1, txtclr1 );
  75.  
  76.     elseif not redstone.getInput(RsInSide) then
  77.         r.setBackgroundColor( clr2 );
  78.         r.clear();
  79.         UIprint(wd, pxl, pyl, text2, txtclr2 );
  80.  
  81.     end
  82. end
  83.  
  84. function UIButton( wd, x, y, wx, wy, text1, text2, clr1, clr2, txtclr1, txtclr2, machine )
  85.     local r = window.create( wd, x, y, wx, wy );
  86.         px = x + 1;
  87.     py = y + math.floor(wy/2);
  88.     if machine.getActive() then
  89.         r.setBackgroundColor( clr1 );
  90.         r.clear();
  91.         UIprint(wd, px, py, text1, txtclr1 );
  92.     else
  93.         r.setBackgroundColor( clr2 );
  94.         r.clear();
  95.         UIprint(wd, px, py, text2, txtclr2 );
  96.     end
  97.    
  98. end
  99.  
  100. function UIFrame( wd, x, y, wx, wy, clr )
  101.         local f = window.create( wd, x, y, wx, wy );
  102.               f.setBackgroundColor( clr );
  103.               f.clear();
  104. end
  105.  
  106. function Setmachine( machine )
  107.     if machine.getActive() then
  108.         machine.setActive(false);
  109.     else
  110.         machine.setActive(true);
  111.     end
  112. end
  113.  
  114. function UIPos( xPos, yPos, xMin, yMin, xWidth, yWidth, Machine)
  115.   if xPos >= xMin then
  116.     if xPos <= (xMin - 1 + xWidth) then
  117.       if yPos >= yMin then
  118.         if yPos <= (yMin + yWidth - 1) then
  119.           Setmachine( Machine );
  120.         end
  121.       end
  122.     end
  123.   end
  124. end
  125.  
  126.  
  127. --Setup--
  128.  
  129. local mw, mh = monitor.getSize()
  130. UIHeader( monitor, 1, 1, mw, 1, "REACTOR MAIN SWITCHES", colors.gray, colors.red);
  131. UIFrame( monitor, 1, 2, mw, 1, colors.gray);
  132. UIHeader( monitor, 1, 2, 11, 1, "Block", colors.gray, colors.white);
  133. UIHeader( monitor, 11, 2, 10, 1, "Status", colors.gray, colors.white);
  134. UIHeader( monitor, 20, 2, 12, 1, "Turbine", colors.gray, colors.white);
  135.  
  136. UIprint( monitor, 2, 4, "Block 1-A:", colors.lightGray );
  137. UIprint( monitor, 2, 5, "Block 1-B:", colors.lightGray );
  138. UIprint( monitor, 2, 6, "Block 2-A:", colors.lightGray );
  139. UIprint( monitor, 2, 7, "Block 2-B:", colors.lightGray );
  140. UIprint( monitor, 2, 8, "Block 3-A:", colors.lightGray );
  141. UIprint( monitor, 2, 9, "Block 3-B:", colors.lightGray );
  142. UIprint( monitor, 2, 10, "Block 4-A:", colors.lightGray );
  143. UIprint( monitor, 2, 11, "Block 4-B:", colors.lightGray );
  144.  
  145. UIButton( monitor, 12, 4, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor1 );
  146. UIButton( monitor, 12, 5, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor2 );
  147. UIButton( monitor, 12, 6, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor3 );
  148. UIButton( monitor, 12, 7, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor4 );
  149. UIButton( monitor, 12, 8, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor5 );
  150. UIButton( monitor, 12, 9, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor6 );
  151. UIButton( monitor, 12, 10, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor7 );
  152. UIButton( monitor, 12, 11, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor8 );
  153.  
  154. UIButton( monitor, 22, 4, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine1 );
  155. UIButton( monitor, 22, 5, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine2 );
  156. UIButton( monitor, 22, 6, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine3 );
  157. UIButton( monitor, 22, 7, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine4 );
  158. UIButton( monitor, 22, 8, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine5 );
  159. UIButton( monitor, 22, 9, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine6 );
  160. UIButton( monitor, 22, 10, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine7 );
  161. UIButton( monitor, 22, 11, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine8 );
  162.  
  163.  
  164. -- RUN --
  165.  
  166. while true do
  167.   event, side, xPos, yPos = os.pullEvent("monitor_touch");
  168.     if event == "monitor_touch" then
  169.  
  170.     UIPos( xPos, yPos, 12, 4, 9, 1, reactor1 );
  171.     UIButton( monitor, 12, 4, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor1 );
  172.  
  173.     UIPos( xPos, yPos, 12, 5, 9, 1, reactor2 );
  174.     UIButton( monitor, 12, 5, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor2 );
  175.  
  176.     UIPos( xPos, yPos, 12, 6, 9, 1, reactor3 );
  177.     UIButton( monitor, 12, 6, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor3 );
  178.  
  179.     UIPos( xPos, yPos, 12, 7, 9, 1, reactor4 );
  180.     UIButton( monitor, 12, 7, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor4 );
  181.  
  182.     UIPos( xPos, yPos, 12, 8, 9, 1, reactor5 );
  183.     UIButton( monitor, 12, 8, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor5 );
  184.  
  185.     UIPos( xPos, yPos, 12, 9, 9, 1, reactor6 );
  186.     UIButton( monitor, 12, 9, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor6 );
  187.  
  188.     UIPos( xPos, yPos, 12, 10, 9, 1, reactor7 );
  189.     UIButton( monitor, 12, 10, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor7 );
  190.  
  191.     UIPos( xPos, yPos, 12, 11, 9, 1, reactor8 );
  192.     UIButton( monitor, 12, 11, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, reactor8 );
  193.  
  194. -- Turbines
  195.  
  196.     UIPos( xPos, yPos, 22, 4, 9, 1, turbine1 );
  197.     UIButton( monitor, 22, 4, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine1 );
  198.  
  199.     UIPos( xPos, yPos, 22, 5, 9, 1, turbine2 );
  200.     UIButton( monitor, 22, 5, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine2 );
  201.  
  202.     UIPos( xPos, yPos, 22, 6, 9, 1, turbine3 );
  203.     UIButton( monitor, 22, 6, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine3 );
  204.  
  205.     UIPos( xPos, yPos, 22, 7, 9, 1, turbine4 );
  206.     UIButton( monitor, 22, 7, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine4 );
  207.  
  208.     UIPos( xPos, yPos, 22, 8, 9, 1, turbine5 );
  209.     UIButton( monitor, 22, 8, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine5 );
  210.  
  211.     UIPos( xPos, yPos, 22, 9, 9, 1, turbine6 );
  212.     UIButton( monitor, 22, 9, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine6 );
  213.  
  214.     UIPos( xPos, yPos, 22, 10, 9, 1, turbine7 );
  215.     UIButton( monitor, 22, 10, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine7 );
  216.  
  217.     UIPos( xPos, yPos, 22, 11, 9, 1, turbine8 );
  218.     UIButton( monitor, 22, 11, 9, 1, "online", "offline", colors.lime, colors.orange, colors.lime, colors.orange, turbine8 );
  219.  
  220.     end
  221. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement