Savage_Me55iah

Server & Terminal v1.7

May 17th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.93 KB | None | 0 0
  1. --Script by Savage_Me55iah of CraftAU.com.au--
  2. --Version 1.7--
  3. --Needs corresponding "Savage Client v1.7" script @ http://pastebin.com/vbdYtpra--
  4. --type "monitor client" to auto download--
  5.  
  6. --INSTRUCTIONS ON USE--
  7. --save this program as startup or monitor and type in startup: shell.run("monitor")--
  8. --example client computer: id-5 label-power
  9. --to add example client type "montior add 5 power"
  10. --to remove example client type "monitor remove 5 power"
  11. --to show settings of buttons type "monitor settings"
  12. --to adjust the settings of script type "edit settings", changing them here won't work once this program has been run once
  13. --to reset everything type "monitor reset"
  14. --buttons will not work without the online button on, turning the online button will shut off all other buttons
  15. --connect the monitors using network cables and wired modems
  16.  
  17.  
  18. local tArgs = { ... }
  19. local command = tostring(tArgs[1]) or false
  20. local name1 = tostring(tArgs[3]) or false
  21. local id = tonumber(tArgs[2]) or false
  22. local name2 = tostring(tArgs[5]) or false
  23. local id2 = tonumber(tArgs[4]) or false
  24.  
  25. --TABLES--
  26. --print("tables")
  27.  
  28. names = {}
  29. ids = {}
  30. status = {}
  31. relays = {}
  32.  
  33. function add_button(command, id, on_off)
  34.   num = table.maxn(names) + 1
  35.   names[num] = command
  36.   ids[num] = id
  37.   status[num] = on_off
  38. end
  39.  
  40. add_button("online", 0, true)
  41.  
  42. local load_save_loc = {
  43.   ["load_save_loc"] = "load_save_loc",
  44.   ["settings"] = "settings",
  45.   ["names"] = "names",
  46.   ["ids"] = "ids",
  47.   ["status"] = "status",
  48.   ["eu"] = "eu",
  49.   ["mj"] = "mj",
  50.   ["relays"] = "relays"
  51. }
  52.  
  53. local settings = {
  54.   ["mon_side"] = "top",
  55.   ["wireless_side"] = "left",
  56.   ["remote_modem"] = "right",
  57.   ["heading color"] = colors.yellow,
  58.   ["heading background"] = colors.black,
  59.   ["heading"] = "Savage Monitor v1.7",
  60.   ["active color"] = colors.green,
  61.   ["inactive color"] = colors.red,
  62.   ["id"] = os.getComputerID(),
  63.   ["label"] = "Server",
  64.   ["refresh_rate"] = 10,
  65.   ["text_scale"] = 1,
  66.   ["button_width"] = 5,
  67.   ["energy_stats"] = false,
  68.   ["open_peripherals"] = false,
  69.   ["direct_power"] = false,
  70.   ["energy_room"] = 0,
  71.   ["eu_id"] = 1000,
  72.   ["mj_id"] = 1001,
  73.   ["screen_saver"] = true,
  74.   ["timeout"] = 50,
  75.   ["image_x"] = 27,
  76.   ["image_y"] = 9,
  77.   ["client"] = "vbdYtpra",
  78.   ["output screen"] = false,
  79.   ["relay"] = false
  80. }
  81.  
  82. local button_x1 = {
  83.   [1] = 2
  84. }
  85.  
  86. local button_x2 = {
  87.   [1] = 12
  88. }
  89.  
  90. local button_y1 = {
  91.   [1] = 4
  92. }
  93.  
  94. local eu = {
  95.   ["max"] = 0,
  96.   ["current"] = 0,
  97.   ["percent"] = 0
  98. }
  99.  
  100. local mj = {
  101.   ["max"] = 0,
  102.   ["current"] = 0,
  103.   ["percent"] = 0
  104. }
  105.  
  106. if not fs.exists("settings") then print("Enter computer label: ") os.setComputerLabel(read() or settings["label"]) settings["label"] = os.getComputerLabel() end
  107.  
  108. --LOAD & SAVE FUNCTIONS--
  109.  
  110. function load()
  111. --  print("Loading...")
  112.   local fileHandle = fs.open (load_save_loc["load_save_loc"], 'r')
  113.   load_save_loc = textutils.unserialize (fileHandle.readAll())
  114.   fileHandle.close()
  115.  
  116.   local fileHandle = fs.open (load_save_loc["settings"], 'r')
  117.   settings = textutils.unserialize (fileHandle.readAll())
  118.   fileHandle.close()
  119.  
  120.   local fileHandle = fs.open (load_save_loc["names"], 'r')
  121.   names = textutils.unserialize (fileHandle.readAll())
  122.   fileHandle.close()
  123.  
  124.   local fileHandle = fs.open (load_save_loc["ids"], 'r')
  125.   ids = textutils.unserialize (fileHandle.readAll())
  126.   fileHandle.close()
  127.  
  128.   local fileHandle = fs.open (load_save_loc["status"], 'r')
  129.   status = textutils.unserialize (fileHandle.readAll())
  130.   fileHandle.close()
  131.  
  132.   local fileHandle = fs.open (load_save_loc["eu"], 'r')
  133.   eu = textutils.unserialize (fileHandle.readAll())
  134.   fileHandle.close()
  135.  
  136.   local fileHandle = fs.open (load_save_loc["mj"], 'r')
  137.   mj = textutils.unserialize (fileHandle.readAll())
  138.   fileHandle.close()
  139.  
  140.   local fileHandle = fs.open (load_save_loc["relays"], 'r')
  141.   relays = textutils.unserialize (fileHandle.readAll())
  142.   fileHandle.close()
  143. end
  144.  
  145. function save()
  146. --  print("Saving...")
  147.   local fileHandle = fs.open (load_save_loc["load_save_loc"], 'w')
  148.   fileHandle.write (textutils.serialize (load_save_loc))
  149.   fileHandle.close()
  150.  
  151.   local fileHandle = fs.open (load_save_loc["settings"], 'w')
  152.   fileHandle.write (textutils.serialize (settings))
  153.   fileHandle.close()
  154.  
  155.   local fileHandle = fs.open (load_save_loc["names"], 'w')
  156.   fileHandle.write (textutils.serialize (names))
  157.   fileHandle.close()
  158.  
  159.   local fileHandle = fs.open (load_save_loc["ids"], 'w')
  160.   fileHandle.write (textutils.serialize (ids))
  161.   fileHandle.close()
  162.  
  163.   local fileHandle = fs.open (load_save_loc["status"], 'w')
  164.   fileHandle.write (textutils.serialize (status))
  165.   fileHandle.close()
  166.  
  167.   local fileHandle = fs.open (load_save_loc["eu"], 'w')
  168.   fileHandle.write (textutils.serialize (eu))
  169.   fileHandle.close()
  170.  
  171.   local fileHandle = fs.open (load_save_loc["mj"], 'w')
  172.   fileHandle.write (textutils.serialize (mj))
  173.   fileHandle.close()
  174.  
  175.   local fileHandle = fs.open (load_save_loc["relays"], 'w')
  176.   fileHandle.write (textutils.serialize (relays))
  177.   fileHandle.close()
  178. end
  179.  
  180. --PERLIMINARY WORKINGS--
  181.  
  182. function imagewrite(code)
  183.   outputFile:write("\n")
  184.   outputFile:write(code)
  185. end
  186.  
  187. image_table = {[1] = "eeeeeeeeeeeeeeeeeeeeeeeeeee",
  188.   [2] = "eeeeeffffffffeefffffefffffe",
  189.   [3] = "eeeeff0000f0feef000ffff00fe",
  190.   [4] = "eeeef0fffffffeef0f00f00f0fe",
  191.   [5] = "eeeeff00ffeeeeef0ff000ff0fe",
  192.   [6] = "efffffff0feeeeefffff0fffffe",
  193.   [7] = "ef0f0000ffeeeeef0fefffef0fe",
  194.   [8] = "efffffffffeeeeefffeeeeefffe",
  195.   [9] = "eeeeeeeeeeeeeeeeeeeeeeeeeee"
  196. }
  197.  
  198. if not fs.exists("image") then
  199.   save()
  200.  
  201. --  fs.delete("startup")
  202. --  outputFile = io.open("startup", "a")
  203. --  text = tostring(shell.getRunningProgram())
  204. --  outputFile:write("shell.run(" .. text .. ")")
  205. --  outputFile:close()
  206.  
  207.   fs.delete("image")
  208.   outputFile = io.open("image", "w")
  209.  
  210.  outputFile:write(image_table[1])
  211.   for num = 2,table.maxn(image_table) do
  212.     imagewrite(image_table[num])
  213.   end
  214.   num = nil
  215.   outputFile:close()
  216. else
  217.   load()
  218. end
  219.  
  220. function freespace()
  221.   a = "locating free space..."
  222.   print(a)
  223.   freespace = table.maxn(names) + 1
  224.   a = "free space located at: "
  225.   print(a .. freespace)
  226. end
  227.  
  228. function target()
  229.   a = "locating target..."
  230.   print(a)
  231.   x = 1
  232.   repeat
  233.     x = x + 1
  234.   until names[x] == name1 or names[x] == nil
  235.   if names[x] == name1 then
  236.     target = x
  237.     a = "target located at: "
  238.     print(a .. target)
  239.   else
  240.     print("target button not found")
  241.     target = "not found"
  242.   end
  243. end
  244.  
  245. function add_button()
  246.   a = "adding..."
  247.   print(a)
  248.   freespace()
  249.   names[freespace] = name1
  250.   ids[freespace] = id
  251.   status[freespace] = false
  252.   a = "add successful"
  253.   print(a)
  254. end
  255.  
  256. function remove_button()
  257.   a = "removing..."
  258.   print(a)
  259.   target()
  260.   if target ~= "not found" then
  261.     freespace()
  262.     source = freespace - 1
  263.     names[target] = names[source]
  264.     ids[target] = ids[source]
  265.     status[target] = status[source]
  266.     names[source] = nil
  267.     ids[source] = nil
  268.     status[source] = nil
  269.     a = "removal successful"
  270.     print(a)
  271.   end
  272. end
  273.  
  274. function change_button()
  275.   print("changing " .. name1 .. id .. " to " .. name2 .. id2)
  276.   remove_button()
  277.   name1 = name2
  278.   id = id2
  279.   add_button()
  280.   print("change successful")
  281. end
  282.  
  283. function show_settings()
  284.   x = 2
  285.   while names[x] ~= nil do
  286.     print(x .. ": " .. names[x] .. " " .. ids[x])
  287.     x = x + 1
  288.   end
  289.   os.pullEvent()
  290. end
  291.  
  292. function save2()
  293.   print("confirm save? Y/N : ")
  294.   if tostring(read()) == "y" then
  295.     save()
  296.   end
  297. end
  298.  
  299. function add_relay()
  300.   num = table.maxn(relays) + 1
  301.   relays[num] = tonumber(id)
  302.   save2()
  303. end
  304.  
  305. if command == "add" then
  306.   add_button()
  307.   save2()
  308. elseif command == "remove" then
  309.   remove_button()
  310.   save2()
  311. --elseif command == "change" then
  312. --  change_button()
  313. --  save2()
  314. elseif command == "settings" then
  315.   show_settings()
  316. elseif command == "client" then
  317.   shell.run("pastebin get " .. variables["client"] .. " client")
  318. elseif command == "addr" then
  319.   add_relay()
  320. end
  321.  
  322. function find_peripheral(t, e)
  323.   e = e or nil
  324.   sides = {[1] = "front", [2] = "back", [3] = "left", [4] = "right", [5] = "top", [6] = "bottom"}
  325.   peripheral_found = false
  326.   for num=1, 6 do
  327.     type = peripheral.getType(sides[num])
  328.     if type == t then
  329.       if e == "wireless" then
  330.         if peripheral.call(sides[num], "isWireless") then
  331.           return sides[num]
  332.         end
  333.       elseif e == "remote" then
  334.         if not peripheral.call(sides[num], "isWireless") then
  335.           return sides[num]
  336.         end
  337.       elseif e == nil then
  338.         return sides[num]
  339.       end
  340.     end
  341.   end
  342. --  print("No " .. t .. " attached to the computer")
  343. end
  344.  
  345. -- MODEM REMOTE CONNECTIONS --
  346.  
  347. remote_monitors = {}
  348. mod = find_peripheral("modem", "remote") or nil
  349. mon = find_peripheral("monitor") or nil
  350. if mon ~= nil then remote_monitors[1] = peripheral.wrap(mon) end
  351. if mod ~= nil then
  352. mod = peripheral.wrap(mod)
  353. local remote_peripherals = mod.getNamesRemote()
  354. remote_types = {}
  355. remote_rec = {}
  356. remote_eu = {}
  357. a = 1
  358. if remote_monitors[1] == nil then b = 1 else b = 2 end
  359. c = 1
  360. d = 1
  361. while remote_peripherals[a] ~= nil do
  362.   remote_types[a] = mod.getTypeRemote(remote_peripherals[a])
  363.   if remote_types[a] == "monitor" then
  364.     remote_monitors[b] = peripheral.wrap(remote_peripherals[a])
  365.     b = b + 1
  366.   end
  367.   if settings["open_peripherals"] and settings["energy_stats"] and settings["direct_power"] then
  368.     if remote_types[a] == "cofh_thermalexpansion_energycell" then
  369.       remote_rec[c] = peripheral.wrap(remote_peripherals[a])
  370.       c = c + 1
  371.     end
  372.     if remote_types[a] == "mfsu" then
  373.       remote_eu[d] = peripheral.wrap(remote_peripherals[a])
  374.       d = d + 1
  375.     end
  376.   end
  377.   a = a + 1
  378. end
  379. end
  380.  
  381. rednet.open(find_peripheral("modem", "wireless"))
  382. if not settings["output screen"] then remote_monitors[1] = term end
  383. mon = remote_monitors[1]
  384. --mon.setTextScale(settings["text_scale"])
  385. oa_x, oa_y = mon.getSize()
  386.  
  387. if settings["energy_stats"] and settings["open_peripherals"] then
  388.   oa_x = oa_x - 10
  389. end
  390.  
  391. reps_x = math.floor(oa_x / (settings["button_width"] + 1))
  392. reps_y = math.floor((oa_y / 2) - 1)
  393. total_buttons = reps_x * reps_y
  394. --print(oa_x .. "," .. oa_y .. " - " .. reps_x .. " x " .. reps_y .. " - " .. total_buttons)
  395.  
  396. --FUNCTIONS DRAWING MONITOR SCREEN--
  397.  
  398. --print("Drawing mon screen")
  399.  
  400. function reset_text()
  401. --  print("Reset text")
  402.   mon.setTextColor(colors.white)
  403.   mon.setBackgroundColor(colors.black)
  404. end
  405.  
  406. function heading()
  407. --  print("heading")
  408.   mon.setCursorPos(2,2)
  409.   mon.setTextColor(settings["heading color"])
  410.   mon.setBackgroundColor(settings["heading background"])
  411.   mon.write(settings["heading"] .. ": " .. settings["label"] .. ":" .. settings["id"])
  412.   reset_text()
  413. end
  414.  
  415.  
  416. function button_draw(number, xpos, ypos)
  417.   mon.setCursorPos(xpos, ypos)
  418.   button_x1[number], button_y1[number] = mon.getCursorPos()
  419.   if names[number] ~= nil then
  420.     if status[number] then
  421.       mon.setBackgroundColor(settings["active color"])
  422.     else
  423.       mon.setBackgroundColor(settings["inactive color"])
  424.     end
  425.     text = names[number]:upper()
  426.     text_length = string.len(text) + 2
  427.     if text_length > settings["button_width"] then
  428.       settings["button_width"] = text_length
  429.     end
  430.     mon.write(" " .. text .. " ")
  431.     currpos_x, currpos_y = mon.getCursorPos()
  432.     while currpos_x ~= (settings["button_width"] + xpos) do
  433.       mon.write(" ")
  434.       currpos_x, currpos_y = mon.getCursorPos()
  435.     end
  436.     button_x2[z], y = mon.getCursorPos()
  437.  
  438.     reset_text()
  439. --    print("Writing button " .. number .. ": " .. names[number] .. ": " .. tostring(status[number]))
  440.   end
  441. end
  442.  
  443. -- ENERGY FUNCTIONS --
  444.  
  445. function box(color, left, top, right, bot)
  446.   term.redirect(mon)
  447.   paintutils.drawLine(right, top, left, top, color)
  448.   paintutils.drawLine(left, top, left, bot, color)
  449.   paintutils.drawLine(right, bot, left, bot, color)
  450.   paintutils.drawLine(right, top, right, bot, color)
  451.   term.restore()
  452. end
  453.  
  454. function decimal(number)
  455.   text = nil
  456.   num = nil
  457.   if number > 999 then
  458. num = number / 1000
  459. text = "K"
  460.     if num > 999 then
  461. num = num / 1000
  462. text = "M"
  463.       if num > 999 then num = num / 1000
  464. text = "B"
  465.       end
  466.     end
  467.   num = math.floor(num)
  468.   end
  469.   a = num or 0
  470.   text = text or 0
  471.   text = a .. text
  472.   return text
  473. end
  474.  
  475. function energy_compile()
  476.   local a = 1
  477.   mj["max"] = 0
  478. mj["current"] = 0
  479. mj["percent"] = 0
  480.   while remote_rec[a] ~= nil do
  481.     mj["max"] = mj["max"] + remote_rec[a].getMaxEnergyStored("north")
  482.     mj["current"] = mj["current"] + remote_rec[a].getEnergyStored("north")
  483.     a = a + 1
  484.   end
  485.  
  486.   local a = 1
  487.   eu["max"] = 0
  488.   eu["current"] = 0
  489.   eu["percent"] = 0
  490.   while remote_eu[a] ~= nil do
  491.     eu["max"] = eu["max"] + remote_eu[a].getCapacity()
  492.     eu["current"] = eu["current"] + remote_eu[a].getStored()
  493.     a = a + 1
  494.   end
  495. end
  496.  
  497.  
  498. function percentage(type)
  499.   if type == "mj" then
  500.     mj["percent"] = mj["current"] / mj["max"] * 100
  501.     return math.floor(mj["percent"])
  502.   elseif type == "eu" then
  503.     eu["percent"] = eu["current"] / eu["max"] * 100
  504.     return math.floor(eu["percent"])
  505.   end
  506. end
  507.  
  508. function greaterx()
  509.   currx = mon.getCursorPos()
  510.   if currx > endx then
  511.     endx = currx
  512.   end
  513. end
  514.  
  515. function energy_stats(startx, starty)
  516.   if settings["direct_power"] then
  517.     energy_compile()
  518.   end
  519.  
  520.   x = startx + 2
  521.   y = starty + 2
  522.  
  523.   mon.setTextColor(colors.white)
  524.  
  525.   mon.setCursorPos(x,y)
  526.   mon.write("EU: " .. decimal(eu["current"]))
  527.   endx = mon.getCursorPos()
  528.   y = y + 1
  529.  
  530.   mon.setCursorPos(x,y)
  531.   mon.write("EU: " .. decimal(eu["max"]))
  532.   greaterx()
  533.   y = y + 1
  534.  
  535.  
  536.   mon.setCursorPos(x,y)
  537.   mon.write("EU: " .. percentage("eu") .. "%")
  538.   greaterx()
  539.   y = y + 2
  540.  
  541.  
  542.   mon.setCursorPos(x,y)
  543.   mon.write("MJ: " .. decimal(mj["current"]) )
  544.   greaterx()
  545.   y = y + 1
  546.  
  547.   mon.setCursorPos(x,y)
  548.   mon.write("MJ: " .. decimal(mj["max"]) )
  549.   greaterx()
  550.   y = y + 1
  551.  
  552.  
  553.   mon.setCursorPos(x,y)
  554.   mon.write("MJ: " .. percentage("mj") .. "%")
  555.   greaterx()
  556.   endy = y + 2
  557.   endx = endx + 1
  558.   box(colors.white, startx, starty, endx, endy)
  559. end
  560.  
  561. -- MONITOR SCREEN PROGRAM --
  562.  
  563. function mon_screen()
  564.  
  565.   screen = 1
  566.   while remote_monitors[screen] ~= nil do
  567.     mon = remote_monitors[screen]
  568.  
  569. --    print("drawing monitor")
  570.  
  571.     mon.clear()
  572.  
  573.     heading()
  574.  
  575.     x = 2
  576.     y = 4
  577.  
  578.     if settings["energy_stats"] then
  579.       energy_stats(x, y)
  580.       settings["energy_room"] = endx
  581.       x = endx + 1
  582.     end
  583.  
  584.     z = 1
  585.  
  586.     for num=1,reps_x do
  587.       y = 4
  588.  
  589.       for num=1,reps_y do
  590.         button_draw(z, x, y)
  591.         y = y + 2
  592.         z = z + 1
  593.       end
  594.  
  595.       x = x + settings["button_width"] + 1
  596.     end
  597.     save()
  598.     screen = screen + 1
  599.   end
  600. end
  601.  
  602. --FUNCTION BUTTON DETECT--
  603.  
  604. function relay(command)
  605.   if command then
  606.     for num = 2,table.maxn(relays) do rednet.send(relays[num], textutils.serialize(names)) end
  607.     sleep(0.1)
  608.     for num = 2,table.maxn(relays) do rednet.send(relays[num], textutils.serialize(ids)) end
  609.     sleep(0.1)
  610.     for num = 2,table.maxn(relays) do rednet.send(relays[num], textutils.serialize(status)) end
  611.   else
  612.     rednet.send(relays[1], textutils.serialize(names))
  613.     sleep(0.1)
  614.     rednet.send(relays[1], textutils.serialize(ids))
  615.     sleep(0.1)
  616.     rednet.send(relays[1], textutils.serialize(status))
  617.   end
  618. end
  619.  
  620. function select_button()
  621.   z = 1
  622.   button_pressed = nil
  623.  
  624.   repeat
  625.     if names[z] ~= nil then
  626.       if x > button_x1[z] and x < button_x2[z] and y == button_y1[z] then
  627.         return z
  628.       end
  629.     end
  630.     z = z + 1
  631.   until z > total_buttons
  632. end
  633.  
  634. function message_send()
  635.   if status[button_pressed] then
  636.     text = "deactivate"
  637.     status[button_pressed] = not status[button_pressed]
  638.   else
  639.     text = "activate"
  640.     status[button_pressed] = not status[button_pressed]
  641.   end
  642.  
  643.   rednet.send(ids[button_pressed], text)
  644. --  print(names[button_pressed] .. " " .. ids[button_pressed] .. " " .. text)
  645.  
  646.  
  647. end
  648.  
  649. function offline()
  650.   status[1] = false
  651.   a = 2
  652.   while names[a] ~= nil do
  653.     if status[a] then
  654.       status[a] = false
  655.       text = "deactivate"
  656.       rednet.send(ids[a], text)
  657.     end
  658.     a = a + 1
  659.   end
  660.   mon_screen()
  661. end
  662.  
  663. -- SCREEN SAVER --
  664.  
  665. function image_draw()
  666.   screen = 1
  667.   image = {}
  668.   image = paintutils.loadImage("image")
  669.   while remote_monitors[screen] ~= nil do
  670.     print("image: " .. screen)
  671.     mon = remote_monitors[screen]
  672.     mon.clear()
  673.     oa_x, oa_y = mon.getSize()
  674.     term.redirect(mon)
  675.     x = (oa_x / 2) - (settings["image_x"] / 2)
  676.     y = (oa_y / 2) - (settings["image_y"] / 2)
  677.     paintutils.drawImage(image, x, y)
  678.     term.restore()
  679.     reset_text()
  680.     screen = screen + 1
  681.   end
  682. end
  683.  
  684.  
  685. function screen_saver()
  686. --  print("screen Saver")
  687.  
  688.   image_draw()
  689.   os.pullEvent("monitor_touch")
  690. end
  691.  
  692. -- PROGRAM --
  693.  
  694. e = 1
  695. mon_screen()
  696. while true do
  697.   if settings["direct_power"] or settings["screen_saver"] or not settings["output screen"] then
  698.     os.startTimer(settings["refresh_rate"])
  699.   end
  700.  
  701.   event, id, x, y  = os.pullEvent()
  702.  
  703.   if event == "monitor_touch" or event == "mouse_click" then
  704.     button_pressed = select_button()
  705.     e = 1
  706.     if names[button_pressed] ~= nil then
  707.       if button_pressed ~= 1 then
  708.         if status[1] then
  709.           message_send()
  710.         end
  711.       else
  712.  
  713.         if status[1] then
  714.           offline()
  715.         else
  716.           status[1] = true
  717. --          startup_buttons
  718.         end
  719.       end
  720.     end
  721.     relay(settings["relay"])
  722.  
  723.   elseif event == "rednet_message" then
  724.  
  725.     text1 = x
  726.     e, i, text2 =os.pullEvent("rednet_message")
  727.     e, i, text3 =os.pullEvent("rednet_message")
  728.     names = textutils.unserialize (text1)
  729.     ids = textutils.unserialize (text2)
  730.     status = textutils.unserialize (text3)
  731.  
  732.     if settings["relay"] then relay(settings["relay"]) end
  733.  
  734.   elseif event == "timer" then
  735. --    print("timer")
  736.     if settings["screen_saver"] then
  737.       e = e + 1
  738. --      print("Timeout: " .. e)
  739.       if e == settings["timeout"] then
  740.         screen_saver()
  741.         e = 1
  742.       end
  743.     end
  744.   end
  745.   mon_screen()
  746. end
Advertisement
Add Comment
Please, Sign In to add comment