sayhisam1

Reactor Modem Host

Jul 31st, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 25.63 KB | None | 0 0
  1. -----BigReactor Control
  2. -----by jaranvil aka jared314
  3.  
  4. -----feel free to use and/or mondify this code
  5. -----------------------------------------------
  6.  
  7. version = 1
  8. term.clear()
  9. -------------------FORMATTING-------------------------------
  10. function clear()
  11.         mon.setBackgroundColor(colors.black)
  12.         mon.clear()
  13.         mon.setCursorPos(1,1)
  14. end
  15.  
  16. function draw_text_term(x, y, text, text_color, bg_color)
  17.         term.setTextColor(text_color)
  18.         term.setBackgroundColor(bg_color)
  19.         term.setCursorPos(x,y)
  20.         write(text)
  21. end
  22.  
  23. function draw_text(x, y, text, text_color, bg_color)
  24.         mon.setBackgroundColor(bg_color)
  25.         mon.setTextColor(text_color)
  26.         mon.setCursorPos(x,y)
  27.         mon.write(text)
  28. end
  29.  
  30. function draw_line(x, y, length, color)
  31.                 mon.setBackgroundColor(color)
  32.                 mon.setCursorPos(x,y)
  33.                 mon.write(string.rep(" ", length))
  34. end
  35.  
  36. function draw_line_term(x, y, length, color)
  37.                 term.setBackgroundColor(color)
  38.                 term.setCursorPos(x,y)
  39.                 term.write(string.rep(" ", length))
  40. end
  41.  
  42. function progress_bar(x, y, length, minVal, maxVal, bar_color, bg_color)
  43.         draw_line(x, y, length, bg_color) --backgoround bar
  44.         local barSize = math.floor((minVal/maxVal) * length)
  45.         draw_line(x, y, barSize, bar_color)     --progress so far
  46. end
  47.  
  48. function progress_bar_term(x, y, length, minVal, maxVal, bar_color, bg_color)
  49.         draw_line_term(x, y, length, bg_color) --backgoround bar
  50.         local barSize = math.floor((minVal/maxVal) * length)
  51.         draw_line_term(x, y, barSize, bar_color)        --progress so far
  52. end
  53.  
  54. function button(x, y, length, text, txt_color, bg_color)
  55.         draw_line(x, y, length, bg_color)
  56.         draw_text((x+2), y, text, txt_color, bg_color)
  57. end
  58.  
  59. function menu_bar()
  60.         draw_line(1, 1, monX, colors.blue)
  61.         draw_text(2, 1, "Power    Tools    Settings", colors.white, colors.blue)
  62.         draw_line(1, 19, monX, colors.blue)
  63.         draw_text(2, 19, "     Turbine Control", colors.white, colors.blue)
  64. end
  65.  
  66. function power_menu()
  67.         draw_line(1, 2, 9, colors.gray)
  68.         draw_line(1, 3, 9, colors.gray)
  69.         if active then
  70.                 draw_text(2, 2, "ON", colors.lightGray, colors.gray)
  71.                 draw_text(2, 3, "OFF", colors.white, colors.gray)
  72.         else
  73.                 draw_text(2, 2, "ON", colors.white, colors.gray)
  74.                 draw_text(2, 3, "OFF", colors.lightGray, colors.gray)
  75.         end
  76. end
  77.  
  78. function tools_menu()
  79.         draw_line(10, 2, 14, colors.gray)
  80.         draw_line(10, 3, 14, colors.gray)
  81.         draw_text(11, 2, "Flow Rate", colors.white, colors.gray)
  82.         draw_text(11, 3, "Coils", colors.white, colors.gray)
  83.        
  84.        
  85. end
  86.  
  87. function settings_menu()
  88.         draw_line(12, 2, 18, colors.gray)
  89.         draw_line(12, 3, 18, colors.gray)
  90.         draw_text(13, 2, "Check for Updates", colors.white, colors.gray)
  91.         draw_text(13, 3, "Reset peripherals", colors.white, colors.gray)
  92. end
  93.  
  94. function popup_screen(y, title, height)
  95.         clear()
  96.         menu_bar()
  97.  
  98.         draw_line(4, y, 22, colors.blue)
  99.         draw_line(25, y, 1, colors.red)
  100.  
  101.         for counter = y+1, height+y do
  102.                 draw_line(4, counter, 22, colors.white)
  103.         end
  104.  
  105.         draw_text(25, y, "X", colors.white, colors.red)
  106.         draw_text(5, y, title, colors.white, colors.blue)
  107. end
  108.  
  109. function save_config()
  110.         sw = fs.open("turbine_config.txt", "w")        
  111.                 sw.writeLine(version)
  112.                 sw.writeLine(side)
  113.                 sw.writeLine(name)
  114.                 sw.writeLine(auto_string)
  115.                 sw.writeLine(on)
  116.                 sw.writeLine(off)
  117.                 sw.writeLine(modemSide)
  118.                 sw.writeLine(modemChannel)
  119.                 sw.writeLine(senderID)
  120.         sw.close()
  121. end
  122.  
  123. function load_config()
  124.         sr = fs.open("turbine_config.txt", "r")
  125.                 version = tonumber(sr.readLine())
  126.                 side = sr.readLine()
  127.                 name = sr.readLine()
  128.                 auto_string = sr.readLine()
  129.                 on = tonumber(sr.readLine())
  130.                 off = tonumber(sr.readLine())
  131.                 modemSide = sr.readLine()
  132.                 modemChannel = sr.readLine()
  133.                 senderID = tonumber(sr.readLine())
  134.         sr.close()
  135. end
  136.  
  137. --------------------------------------------------
  138.  
  139.  
  140.  
  141. function homepage()
  142.         while true do
  143.                 clear()
  144.                 menu_bar()
  145.                 terminal_screen()
  146.  
  147.                 active = turbine.getActive()
  148.                 energy_stored = turbine.getEnergyStored()
  149.                
  150.  
  151.                 --------POWER STAT--------------
  152.                 draw_text(2, 3, "Power: ", colors.yellow, colors.black)
  153.                
  154.                 if active then
  155.                         draw_text(10, 3, "ONLINE", colors.lime, colors.black)
  156.                 else
  157.                         draw_text(10, 3, "OFFLINE", colors.red, colors.black)
  158.                 end
  159.  
  160.  
  161.                 -----------Router speed---------------------
  162.                 draw_text(2, 5, "Router Speed: ", colors.yellow, colors.black)
  163.                 local maxVal = 2000
  164.                 local minVal = math.floor(turbine.getRotorSpeed())
  165.                 draw_text(19, 5, minVal.." rpm", colors.white, colors.black)
  166.  
  167.                 if minVal < 700 then
  168.                 progress_bar(2, 6, monX-2, minVal, maxVal, colors.lightBlue, colors.gray)
  169.                 else if minVal < 900 then      
  170.                 progress_bar(2, 6, monX-2, minVal, maxVal, colors.lime, colors.gray)
  171.                 else if minVal < 1700 then
  172.                 progress_bar(2, 6, monX-2, minVal, maxVal, colors.lightBlue, colors.gray)
  173.                 else if minVal < 1900 then
  174.                 progress_bar(2, 6, monX-2, minVal, maxVal, colors.lime, colors.gray)
  175.                 else if minVal < 2000 then
  176.                 progress_bar(2, 6, monX-2, minVal, maxVal, colors.yellow, colors.gray)
  177.                 else if minVal >= 2000 then
  178.                 progress_bar(2, 6, monX-2, minVal, maxVal, colors.red, colors.gray)
  179.                 end
  180.                 end
  181.                 end
  182.                 end
  183.                 end
  184.                 end
  185.  
  186.                 -----------Steam Level---------------------
  187.                 draw_text(2, 8, "Steam Amount: ", colors.yellow, colors.black)
  188.                 local maxVal = 4000
  189.                 local minVal = math.floor(turbine.getInputAmount())
  190.                 draw_text(19, 8, minVal.." mB", colors.white, colors.black)
  191.                 progress_bar(2, 9, monX-2, minVal, maxVal, colors.lightGray, colors.gray)
  192.                
  193.  
  194.                 -----------Water Level---------------------
  195.                 draw_text(2, 11, "Water Amount: ", colors.yellow, colors.black)
  196.                 local maxVal = 4000
  197.                 local minVal = math.floor(turbine.getOutputAmount())
  198.                 draw_text(19, 11, minVal.." mB", colors.white, colors.black)
  199.                 progress_bar(2, 12, monX-2, minVal, maxVal, colors.blue, colors.gray)
  200.        
  201.  
  202.                 -------------OUTPUT-------------------
  203.                 draw_text(2, 14, "RF/tick: ", colors.yellow, colors.black)
  204.                 rft = math.floor(turbine.getEnergyProducedLastTick())
  205.                 draw_text(19, 14, rft.." RF/T", colors.white, colors.black)
  206.  
  207.                 -----------RF STORAGE---------------
  208.                 draw_text(2, 15, "RF Stored:", colors.yellow, colors.black)
  209.                 local maxVal = 1000000
  210.                 local minVal = energy_stored
  211.                 local percent = math.floor((energy_stored/maxVal)*100)
  212.                 draw_text(19, 15, percent.."%", colors.white, colors.black)
  213.  
  214.                 ------------FLOW RATE----------------
  215.                 draw_text(2, 16, "Flow Rate: ", colors.yellow, colors.black)
  216.                 flow_rate = turbine.getFluidFlowRateMax()
  217.                 draw_text(19, 16, flow_rate.." mB/t", colors.white, colors.black)
  218.  
  219.                 ------------COILS---------------------------
  220.                 engaged = turbine.getInductorEngaged()
  221.                 draw_text(2, 17, "Coils: ", colors.yellow, colors.black)
  222.  
  223.                 if engaged then
  224.                         draw_text(19, 17, "Engaged", colors.white, colors.black)
  225.                 else
  226.                         draw_text(19, 17, "Disengaged", colors.white, colors.black)
  227.                 end
  228.  
  229.  
  230.                
  231.                 sleep(0.5)
  232.         end
  233. end
  234.  
  235. --------------MENU SCREENS--------------
  236.  
  237.  
  238.  
  239. -------------------Tools----------------------
  240.  
  241. function flow_rate_menu()
  242.         popup_screen(3, "Flow Rate", 12)
  243.         flow_rate = turbine.getFluidFlowRateMax()
  244.         current_flow = turbine.getFluidFlowRate()
  245.  
  246.         draw_text(5, 5, "Steam consumption", colors.lime, colors.white)
  247.         draw_text(5, 6, "last tick:", colors.lime, colors.white)
  248.         draw_text(13, 8, current_flow.." mB", colors.black, colors.white)
  249.  
  250.         draw_text(5, 10, "Flow Rate Setting:", colors.lime, colors.white)
  251.         draw_text(8, 12, " < ", colors.white, colors.black)
  252.         draw_text(13, 12, flow_rate.." mB", colors.black, colors.white)
  253.         draw_text(21, 12, " > ", colors.white, colors.black)
  254.  
  255.         draw_text(13, 14, " Okay ", colors.white, colors.black)
  256.  
  257.         local event, side, xPos, yPos = os.pullEvent("monitor_touch")
  258.  
  259.         --decrease
  260.         if yPos == 12 and xPos >= 8 and xPos <= 11 then
  261.                 turbine.setFluidFlowRateMax(flow_rate-10)
  262.                 flow_rate_menu()
  263.         --increase
  264.         else if yPos == 12 and xPos >= 21 and xPos <= 24 then
  265.                 turbine.setFluidFlowRateMax(flow_rate+10)
  266.                 flow_rate_menu()
  267.         end
  268.         end
  269.  
  270.         --Okay button
  271.         if yPos == 14 and xPos >= 13 and xPos <= 19 then
  272.                 call_homepage()
  273.         end
  274.  
  275.         --Exit button
  276.         if yPos == 3 and xPos == 25 then
  277.                 call_homepage()
  278.         end
  279.         flow_rate_menu()
  280. end
  281.  
  282.  
  283. function coil_menu()
  284.         engaged = turbine.getInductorEngaged()
  285.  
  286.         popup_screen(3, "Induction Coils", 8)
  287.         draw_text(5, 5, "Coil Status:", colors.black, colors.white)
  288.  
  289.         if engaged then
  290.                 draw_text(5, 6, "Engaged", colors.lime, colors.white)
  291.                 draw_text(10, 8, " Disengage ", colors.white, colors.black)
  292.         else
  293.                 draw_text(5, 6, "Disengaged", colors.red, colors.white)
  294.                 draw_text(10, 8, " Engage ", colors.white, colors.black)
  295.         end
  296.  
  297.         draw_text(12, 10, " Okay ", colors.white, colors.black)
  298.  
  299.  
  300.         local event, side, xPos, yPos = os.pullEvent("monitor_touch")
  301.  
  302.         if yPos == 8 and xPos >= 10 and xPos <= 21 then
  303.                 if engaged then
  304.                         turbine.setInductorEngaged(false)
  305.                         coil_menu()
  306.                 else
  307.                         turbine.setInductorEngaged(true)
  308.                         coil_menu()
  309.                 end
  310.         end
  311.  
  312.         --okay button
  313.         if yPos == 10 and xPos >= 12 and xPos <= 18 then
  314.                 call_homepage()
  315.         end
  316.  
  317.  
  318.         coil_menu()
  319. end
  320.  
  321. -----------------------Settings--------------------------------
  322.  
  323.  
  324.  
  325. function install_update(program, pastebin)
  326.                 clear()
  327.                 draw_line(4, 5, 22, colors.blue)
  328.  
  329.                 for counter = 6, 10 do
  330.                         draw_line(4, counter, 22, colors.white)
  331.                 end
  332.  
  333.                 draw_text(5, 5, "Updating...", colors.white, colors.blue)
  334.                 draw_text(5, 7, "Open computer", colors.black, colors.white)
  335.                 draw_text(5, 8, "terminal.", colors.black, colors.white)
  336.  
  337.                 if fs.exists("install") then fs.delete("install") end
  338.                 shell.run("pastebin get p4zeq7Ma install")
  339.                 shell.run("install")
  340.  
  341. end
  342.  
  343. function update()
  344.         popup_screen(5, "Updates", 4)
  345.         draw_text(5, 7, "Connecting to", colors.black, colors.white)
  346.         draw_text(5, 8, "pastebin...", colors.black, colors.white)
  347.  
  348.         sleep(0.5)
  349.        
  350.         shell.run("pastebin get QP3qrzNu current_version.txt")
  351.         sr = fs.open("current_version.txt", "r")
  352.         current_version = tonumber(sr.readLine())
  353.         sr.close()
  354.         fs.delete("current_version.txt")
  355.         terminal_screen()
  356.  
  357.         if current_version > version then
  358.  
  359.                 popup_screen(5, "Updates", 7)
  360.                 draw_text(5, 7, "Update Available!", colors.black, colors.white)
  361.                 draw_text(11, 9, " Intall ", colors.white, colors.black)
  362.                 draw_text(11, 11, " Ignore ", colors.white, colors.black)
  363.  
  364.                 local event, side, xPos, yPos = os.pullEvent("monitor_touch")
  365.  
  366.                 --Instatll button
  367.                 if yPos == 9 and xPos >= 11 and xPos <= 17 then
  368.                         install_update()
  369.                 end
  370.  
  371.                 --Exit button
  372.                 if yPos == 5 and xPos == 25 then
  373.                         call_homepage()
  374.                 end
  375.                 call_homepage()
  376.  
  377.         else
  378.                 popup_screen(5, "Updates", 5)
  379.                 draw_text(5, 7, "You are up to date!", colors.black, colors.white)
  380.                 draw_text(11, 9, " Okay ", colors.white, colors.black)
  381.  
  382.                 local event, side, xPos, yPos = os.pullEvent("monitor_touch")
  383.  
  384.                 --Okay button
  385.                 if yPos == 9 and xPos >= 11 and xPos <= 17 then
  386.                         call_homepage()
  387.                 end
  388.  
  389.                 --Exit button
  390.                 if yPos == 5 and xPos == 25 then
  391.                         call_homepage()
  392.                 end
  393.                 call_homepage()
  394.         end
  395.  
  396.        
  397.  
  398. end
  399.  
  400. function reset_peripherals()
  401.         clear()
  402.         draw_line(4, 5, 22, colors.blue)
  403.  
  404.         for counter = 6, 10 do
  405.                 draw_line(4, counter, 22, colors.white)
  406.         end
  407.  
  408.         draw_text(5, 5, "Reset Peripherals", colors.white, colors.blue)
  409.         draw_text(5, 7, "Open computer", colors.black, colors.white)
  410.         draw_text(5, 8, "terminal.", colors.black, colors.white)
  411.         setup_wizard()
  412.  
  413. end
  414.  
  415. --stop running status screen if monitors was touched
  416. function stop()
  417.         while true do
  418.                 local event, side, xPos, yPos = os.pullEvent("monitor_touch")
  419.                         x = xPos
  420.                         y = yPos
  421.                         stop_function = "monitor_touch"
  422.                 return
  423.         end    
  424. end
  425.  
  426. function mon_touch()
  427.         --when the monitor is touch on the homepage
  428.         if y == 1 then
  429.                         if x < monX/3 then
  430.                                 power_menu()
  431.                                 local event, side, xPos, yPos = os.pullEvent("monitor_touch")
  432.                                 if xPos < 9 then
  433.                                         if yPos == 2 then
  434.                                                 turbine.setActive(true)
  435.                                                 call_homepage()
  436.                                         else if yPos == 3 then
  437.                                                 turbine.setActive(false)
  438.                                                 call_homepage()
  439.                                         else
  440.                                                 call_homepage()
  441.                                         end
  442.                                         end
  443.                                 else
  444.                                         call_homepage()
  445.                                 end
  446.                                
  447.                         else if x < 20 then
  448.                                 tools_menu()
  449.                                 local event, side, xPos, yPos = os.pullEvent("monitor_touch")
  450.                                 if xPos < 25 and xPos > 10 then
  451.                                         if yPos == 2 then
  452.                                                 flow_rate_menu()
  453.                                         else if yPos == 3 then
  454.                                                 coil_menu()
  455.                                         else if yPos == 4 then
  456.                                                
  457.                                         else if yPos == 5 then
  458.                                        
  459.                                         else
  460.                                                 call_homepage()
  461.                                         end
  462.                                         end
  463.                                         end
  464.                                         end
  465.                                 else
  466.                                         call_homepage()
  467.                                 end
  468.                         else if x < monX then
  469.                                 settings_menu()
  470.                                 local event, side, xPos, yPos = os.pullEvent("monitor_touch")
  471.                                 if xPos > 13 then
  472.                                         if yPos == 2 then
  473.                                                 update()
  474.                                         else if yPos == 3 then
  475.                                                 reset_peripherals()    
  476.                                         else
  477.                                                 call_homepage()
  478.                                         end
  479.                                         end
  480.                                 else
  481.                                         call_homepage()
  482.                                 end
  483.                         end
  484.                         end
  485.                         end
  486.                 else
  487.                         call_homepage()
  488.                 end
  489. end
  490.  
  491. function terminal_screen()
  492.         term.clear()
  493.         draw_line_term(1, 1, 55, colors.blue)
  494.         draw_text_term(13, 1, "BigReactor Controls", colors.white, colors.blue)
  495.         draw_line_term(1, 19, 55, colors.blue)
  496.         draw_text_term(13, 19, "by jaranvil aka jared314", colors.white, colors.blue)
  497.  
  498.         draw_text_term(1, 3, "Current program:", colors.white, colors.black)
  499.         draw_text_term(1, 4, "Turbine Control v"..version, colors.blue, colors.black)
  500.        
  501.         draw_text_term(1, 6, "Installer:", colors.white, colors.black)
  502.         draw_text_term(1, 7, "pastebin.com/p4zeq7Ma", colors.blue, colors.black)
  503.  
  504.         draw_text_term(1, 9, "Please give me your feedback, suggestions,", colors.white, colors.black)
  505.         draw_text_term(1, 10, "and errors!", colors.white, colors.black)
  506.  
  507.         draw_text_term(1, 11, "reddit.com/r/br_controls", colors.blue, colors.black)
  508. end
  509.  
  510. --run both homepage() and stop() until one returns
  511. function call_homepage()
  512.         clear()
  513.         parallel.waitForAny(homepage, stop)
  514.  
  515.         if stop_function == "terminal_screen" then
  516.                 stop_function = "nothing"
  517.                 setup_wizard()
  518.         else if stop_function == "monitor_touch" then
  519.                 stop_function = "nothing"
  520.                 mon_touch()
  521.         end
  522.         end
  523. end
  524.  
  525. --try to wrap peripherals
  526. --catch any errors
  527.         function test_turbine_connection()
  528.                 turbine = relay("peripheral.wrap(\"bottom\")")  --wrap reactor
  529.                 print("Turbine wrapped!")
  530.                 c = turbine.getConnected()
  531.                 print("Turbine Connected!")
  532.             if unexpected_condition then error() end  
  533.         end
  534.  
  535.         function test_monitor_connection()
  536.                 mon = peripheral.wrap(side) --wrap mon
  537.                 monX, monY = mon.getSize() --get mon size ()
  538.             if unexpected_condition then error() end  
  539.         end
  540.         function test_modem_connection()
  541.                 local periphwrap = "peripheral.wrap(\"bottom\")"
  542.                 rednet.open(modemSide)
  543.                 rednet.broadcast(periphwrap,modemChannel)
  544.                 while rednet.receive(modemChannel,5) == nil do
  545.                     rednet.broadcast(periphwrap,modemChannel)
  546.                 end
  547.                 senderID,message,protocol = rednet.receive(modemChannel)
  548.             if unexpected_condition then error() end
  549.         end
  550. --test if the entered monitor and reactor can be wrapped
  551.         function test_configs()
  552.  
  553.                 term.clear()
  554.                 draw_line_term(1, 1, 55, colors.blue)
  555.                 draw_text_term(10, 1, "BigReactor Controls v"..version, colors.white, colors.blue)
  556.                 draw_line_term(1, 19, 55, colors.blue)
  557.                 draw_text_term(10, 19, "by jaranvil aka jared314 - Wireless Modem Support by sayhisam1", colors.white, colors.blue)
  558.  
  559.                 draw_text_term(1, 2, "Wrapping peripherals...", colors.blue, colors.black)
  560.                 sleep(0.1)
  561.                 draw_text_term(2, 3, "Connecting to Rednet...", colors.white, colors.black)
  562.                 sleep(0.1)
  563.                 if pcall(test_modem_connection) then
  564.                         draw_text_term(18, 3, "success", colors.lime, colors.black)
  565.                 else
  566.                         test_configs()
  567.                 end
  568.         draw_text_term(2, 4, "wrap montior...", colors.white, colors.black)
  569.                 if pcall(test_monitor_connection) then
  570.                         draw_text_term(18, 4, "success", colors.lime, colors.black)
  571.                 else
  572.                         draw_text_term(1, 4, "Error:", colors.red, colors.black)
  573.                         draw_text_term(1, 8, "Could not connect to monitor on "..side.." side", colors.red, colors.black)
  574.                         draw_text_term(1, 9, "Valid sides are 'left', 'right', 'top', 'bottom' and 'back'", colors.white, colors.black)
  575.                         draw_text_term(1, 11, "Press Enter to continue...", colors.gray, colors.black)
  576.                         wait = read()
  577.                         setup_wizard()
  578.                 end
  579.                 sleep(0.1)
  580.                 draw_text_term(2, 5, "wrap turbine...", colors.white, colors.black)
  581.                 sleep(0.1)
  582.                 if pcall(test_turbine_connection) then
  583.                         draw_text_term(18, 5, "success", colors.lime, colors.black)
  584.                 else
  585.                         draw_text_term(1, 8, "Error:", colors.red, colors.black)
  586.                         draw_text_term(1, 9, "Could not connect to "..name, colors.red, colors.black)
  587.                         draw_text_term(1, 10, "Turbine must be connected with networking cable and wired modem", colors.white, colors.black)
  588.                         draw_text_term(1, 12, "Press Enter to continue...", colors.gray, colors.black)
  589.                         wait = read()
  590.                         setup_wizard()
  591.                 end
  592.                 sleep(0.1)
  593.                 draw_text_term(2, 8, "saving settings to file...", colors.white, colors.black)
  594.  
  595.                 save_config()
  596.  
  597.                 sleep(0.1)
  598.                 draw_text_term(1, 10, "Setup Complete!", colors.lime, colors.black)    
  599.                 sleep(3)
  600.  
  601.                 auto = auto_string == "true"
  602.                 call_homepage()
  603.  
  604. end
  605. ----------------SETUP-------------------------------
  606.  
  607. function setup_wizard()
  608.         term.clear()
  609.         draw_text_term(1, 1, "BigReactor Controls v"..version, colors.lime, colors.black)
  610.         draw_text_term(1, 2, "Peripheral setup wizard", colors.white, colors.black)
  611.         draw_text_term(1, 4, "Step 1:", colors.lime, colors.black)
  612.         draw_text_term(1, 5, "-Place 3x3 advanced monitors next to computer.", colors.white, colors.black)
  613.         draw_text_term(1, 7, "Step 2:", colors.lime, colors.black)
  614.         draw_text_term(1, 8, "-Place a wired modem on this computer and on the ", colors.white, colors.black)
  615.         draw_text_term(1, 9, " computer port of the turbine.", colors.white, colors.black)
  616.         draw_text_term(1, 10, "-connect modems with network cable.", colors.white, colors.black)
  617.         draw_text_term(1, 11, "-right click modems to activate.", colors.white, colors.black)
  618.         draw_text_term(1, 13, "Press Enter when ready...", colors.gray, colors.black)
  619.        
  620.         wait = read()
  621.        
  622.         term.clear()
  623.         draw_text_term(1, 1, "Peripheral Setup", colors.lime, colors.black)
  624.         draw_text_term(1, 3, "What side is your monitor on?", colors.yellow, colors.black)
  625.  
  626.         term.setTextColor(colors.white)
  627.         term.setCursorPos(1,4)
  628.         side = read()
  629.  
  630.         term.clear()
  631.         draw_text_term(1, 1, "Peripheral Setup", colors.lime, colors.black)
  632.         draw_text_term(1, 3, "What is the turbine's name?", colors.yellow, colors.black)
  633.         draw_text_term(1, 4, "type 'default' for  'BigReactors-Turbine_0'", colors.gray, colors.black)
  634.  
  635.         term.setTextColor(colors.white)
  636.         term.setCursorPos(1,5)
  637.         name = read()
  638.  
  639.         term.clear()
  640.         draw_text_term(1, 1, "Peripheral Setup", colors.lime, colors.black)
  641.         draw_text_term(1, 3, "What side is your modem on?", colors.yellow, colors.black)
  642.        
  643.         term.setTextColor(colors.white)
  644.         term.setCursorPos(1,5)
  645.         modemSide = read()
  646.        
  647.         term.clear()
  648.         draw_text_term(1, 1, "Peripheral Setup", colors.lime, colors.black)
  649.         draw_text_term(1, 3, "What channel should rednet broadcast on?", colors.yellow, colors.black)
  650.        
  651.         term.setTextColor(colors.white)
  652.         term.setCursorPos(1,5)
  653.         modemChannel = read()
  654.        
  655.         if name == "default" then name = "BigReactors-Turbine_0" end
  656.         auto_string = false
  657.         on = 0
  658.         off = 99
  659.  
  660.         test_configs()
  661. end
  662.  
  663. function start()
  664.         --if configs exists, load values and test
  665.         if fs.exists("turbine_config.txt") then
  666.                         load_config()
  667.  
  668.                         test_configs()
  669.         else
  670.                 setup_wizard()
  671.         end
  672. end
  673.  
  674.  function relay(msg)
  675.         shell.run("clear")
  676.         rednet.open(modemSide)
  677.         rednet.broadcast(msg, modemChannel)
  678.         local a,b,c = rednet.receive(modemChannel)
  679.         print (b)
  680.         return b
  681.  end
  682. start()
Add Comment
Please, Sign In to add comment