Advertisement
DemiGod2B

Base Monitor OpenComputers

Mar 17th, 2018
2,014
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.17 KB | None | 1 0
  1. --[[
  2.     Base Monitor(oc) 1.8
  3.         This script allows you to monitor caches, tanks, barrels and chests
  4.         Monitoring chests requires an open peripheral proxy, the same goes for
  5.         buildcraft tanks.
  6.         You can build one of more computers and set one of them as the main server by
  7.         setting isMain to true. This will let it receive information from other computers.
  8.         For the main server to receive info from other computers you need to attach a
  9.         wireless modem to each computer.
  10.         Peripherals can be attached to any side you like, the script will automatically
  11.         work out where the peripherals are.
  12. Changes since 1.7
  13.         Changed the sorting of the items to be alphabetical
  14.     Changes since 1.6
  15.         Made significant changed to how peripherals are checked and processed.
  16.         Redesigned how the contents is processed and stored so that there is a timestamp.
  17.         The timestamp allows remote computer information to be processed correctly.
  18.         Each computer must have a unique id set, if the same id is used for two systems,
  19.         then the last one to update the table will win and you won't see all the content.
  20.         Added ItemsFullPercentAt, EnergyFullPercentAt and FluidFullPercentAt to set what
  21.         level is considered full. Added support for the OC XNet Driver.
  22.     Changes since 1.5
  23.         First version of Base Monitor for OpenComputers
  24.         Still in a very eary testing phase, no wireless testing has started yet.
  25.         See http://youtu.be/KT-2hKjUpGA for the ComputerCraft version
  26. --]]
  27. component = require("component")
  28. event = require("event")
  29. os = require("os")
  30. term = require("term")
  31. local updateCount = 0;
  32. -- Below are values you can change
  33. local isMain = false;
  34. --local id = os.computerID();
  35. local id = "Main Base";
  36. local VersionInfo = "Base Monitor(oc) 1.8";
  37.  
  38. local titleTextColor = 0x0000FF;
  39. local titleBackColor = 0xFFFFFF;
  40. local tankTextColor = 0xEBFF0B;
  41. local tankBackColor = 0x2A8E2A;
  42. local chestTextColor = 0xFFFFFF;
  43. local chestBackColor = 0x37ADAD;
  44. local gasTextColor = 0xFFFFFF;
  45. local gasBackColor = 0xAA00AA;
  46. local powerTextColor = 0xFFA800;
  47. local powerBackColor = 0xFF00AA;
  48.  
  49. local UpdateIntervalSeconds = 60;
  50.  
  51. local ItemsFullPercentAt = 640;
  52. local EnergyFullPercentAt = 2000000;
  53. local FluidFullPercentAt = 640000;
  54. local GasFullPercentAt = 640000;
  55.  
  56. --component.gpu.setResolution(140,40);
  57.  
  58. --[[
  59.     Add or remove values here to exclude items from being displayed.
  60.     It is case insensitive and it will look for matches.
  61.     So an item called "Nether Brick" will not be displayed if any of the following is set
  62.     "Brick","brick","rick","ck"
  63.     This also means that of you set a filter call "iron" then it will remove all items containing iron.
  64.     it will not show Iron Ore, Iron Block, Iron Helmet, etc.
  65. --]]
  66. local blacklist = {"Flesh","Nugget","Brain","Sapling","Seed","egg","eye"};
  67. --[[
  68.     Add or remove values here to only show items matching these names.
  69.     It is case insensitive and it will look for matches.
  70.     So an item called "Nether Brick" will be displayed if any of the following is set
  71.     "Brick","brick","rick","ck"
  72.     This also means that of you set a filter called "iron" then it will show all items containing iron.
  73.     it will show show Iron Ore, Iron Block, Iron Helmet, etc.
  74.     To disable the whitelist set it to local whitelist = "";
  75.     To enable the whitelist set it to local whitelist = {"Diamond","Gold"};
  76. --]]
  77. local whitelist = "";
  78. --local whitelist = {"Ingot"};
  79.  
  80. local NameLen = 17;
  81. local mainChannel = 2;
  82.  
  83. -- Above are values you can change
  84.  
  85. function statuslog(strMsg)
  86.     local x,y = component.gpu.getResolution();
  87.     term.setCursor(1,y);
  88.     term.clearLine();
  89.     term.write(strMsg);
  90. end
  91.  
  92. function printclock()
  93.     local x,y = component.gpu.getResolution();
  94.     term.setCursor(x-5,1);
  95.     local now = os.date();
  96.     now = string.sub(now,string.find(now," ")+1,-4)
  97.     term.write(now);
  98. end
  99.  
  100. statuslog("Starting "..VersionInfo);
  101. --local mon;
  102. local wmod;
  103. local x,y;
  104. local CurColumn = 0;
  105. local MaxColumn;
  106. local ColumnWidth;
  107. local CurLine = 2;
  108. local ContentData = {};
  109.  
  110. function padString (sText, iLen)
  111.     local iTextLen = string.len(sText);
  112.     -- Too short, pad
  113.     if (iTextLen < iLen) then
  114.         local iDiff = iLen - iTextLen;
  115.         return(sText..string.rep(" ",iDiff));
  116.     end
  117.     -- Too long, trim
  118.     if (iTextLen > iLen) then
  119.         return(string.sub(sText,1,iLen));
  120.     end
  121.     -- Exact length
  122.     return(sText);
  123. end
  124.  
  125. function checkDepth()
  126.     if (component.gpu.getDepth() == 1) then
  127.         titleTextColor = 0x000000;
  128.         titleBackColor = 0xffffff;
  129.         tankTextColor = 0x000000;
  130.         tankBackColor = 0xffffff;
  131.         chestTextColor = 0x000000;
  132.         chestBackColor = 0xffffff;
  133.         gasTextColor = 0x000000;
  134.         gasBackColor = 0xffffff;
  135.         powerTextColor = 0x000000;
  136.         powerBackColor = 0xffffff;
  137.     end
  138. end
  139.  
  140. function updateTable(strSource,strName,strAmount,timestamp,strLegend)
  141.     local isWhitelisted = true;
  142.     if (type(whitelist) == "table") then
  143.         isWhitelisted = false;
  144.         for l,filter in pairs(whitelist) do
  145.             if (string.find(string.lower(strName),string.lower(filter)) ~= nil) then
  146.                 isWhitelisted = true;
  147.             end
  148.         end
  149.     end
  150.     if (isWhitelisted == false) then
  151.         return;
  152.     end
  153.     if (type(blacklist) == "table") then
  154.         for l,filter in pairs(blacklist) do
  155.             if (string.find(string.lower(strName),string.lower(filter)) ~= nil) then
  156.                 return;
  157.             end
  158.         end
  159.     end
  160.     if (ContentData[strSource] == nil) then
  161.         ContentData[strSource] = {};
  162.     end
  163.     if (ContentData[strSource][timestamp] == nil) then
  164.         ContentData[strSource][timestamp] = {};
  165.     end
  166.     if (ContentData[strSource][timestamp][strName] == nil) then
  167.         ContentData[strSource][timestamp][strName] = {};
  168.     end
  169.     if (ContentData[strSource][timestamp][strName]["count"] == nil) then
  170.         ContentData[strSource][timestamp][strName]["count"] = strAmount;
  171.     else
  172.         ContentData[strSource][timestamp][strName]["count"] = ContentData[strSource][timestamp][strName]["count"] + strAmount;
  173.     end
  174.     ContentData[strSource][timestamp][strName]["legend"] = strLegend;
  175. end
  176.  
  177. function printmon(strName,strAmount,strMax,strLegend)
  178.     local textColor;
  179.     local backColor;
  180.     local FullPercentAt = ItemsFullPercentAt;
  181.     if (strLegend == "#") then
  182.         textColor = chestTextColor;
  183.         backColor = chestBackColor;
  184.         strLegend = "";
  185.     end
  186.     if (strLegend == "+") then
  187.         textColor = tankTextColor;
  188.         backColor = tankBackColor;
  189.         FullPercentAt = FluidFullPercentAt;
  190.         strLegend = "";
  191.     end
  192.     if (strLegend == "*") then
  193.         textColor = powerTextColor;
  194.         backColor = powerBackColor;
  195.         FullPercentAt = EnergyFullPercentAt;
  196.         strLegend = "";
  197.     end
  198.     if (strLegend == "$") then
  199.         textColor = gasTextColor;
  200.         backColor = gasBackColor;
  201.         FullPercentAt = GasFullPercentAt;
  202.         strLegend = "";
  203.     end
  204.     local line = string.format("%s  %3i%s",padString(strName,NameLen+1),strAmount,padString(strLegend,1));
  205.     if (strAmount >= 1000000) then
  206.         line = string.format("%s  %3iM%s",padString(strName,NameLen),math.floor(strAmount/1000000),padString(strLegend,1));
  207.     elseif (strAmount >= 1000) then
  208.         line = string.format("%s  %3iK%s",padString(strName,NameLen),math.floor(strAmount/1000),padString(strLegend,1));
  209.     end
  210.  
  211.     local ColPadding = 0;
  212.     if (CurColumn > 0) then
  213.         ColPadding = 1;
  214.     end
  215.     local CurX = math.floor((CurColumn*ColumnWidth))+math.floor(CurColumn*ColPadding)+1;
  216.  if (CurColumn == 0) then
  217.     --  statuslog("CurX:"..CurX);
  218.  end
  219.     term.setCursor(CurX,CurLine);
  220.     local percent = 0;
  221.     if (strMax == 0) then
  222.         percent = strAmount / FullPercentAt * 100;
  223.     else
  224.         percent = strAmount / strMax * 100;
  225.     end
  226.     component.gpu.setBackground(backColor);
  227.     if ((strAmount >= FullPercentAt) and (strMax == 0)) then
  228.         percent = 100;
  229.     end
  230.     local barlength = math.floor(percent / 100 * (string.len(line)-1));
  231.  --if (CurColumn == 0) then
  232.    --barlength = barlength + 1;
  233.  --end
  234.  
  235.     if (string.len(line) > barlength) then
  236.         local msg = string.sub(line,1,barlength);
  237.         component.gpu.setForeground(textColor);
  238.         term.write(msg);
  239.         if (percent == 0) then
  240.             component.gpu.setBackground(backColor);
  241.         else
  242.             component.gpu.setBackground(0x000000);
  243.         end
  244.         if (component.gpu.getDepth() == 1) then
  245.             component.gpu.setForeground(0xffffff);
  246.         end
  247.         term.write(string.sub(line,barlength+1,-2))
  248.     else
  249.         local spaces = barlength - string.len(line);
  250.         term.write(line);
  251.         term.write(string.rep(" ",spaces));
  252.     end
  253.  
  254.     component.gpu.setForeground(0xFFFFFF);
  255.     component.gpu.setBackground(0x000000);
  256.     CurColumn = CurColumn + 1;
  257.     if (CurColumn > MaxColumn) then
  258.         CurColumn = 0;
  259.         CurLine = CurLine + 1;
  260.     end
  261.     return true;
  262. end
  263.  
  264. -- Find the largest screen
  265. function findScreen()
  266.     for i,name in pairs(component.list()) do
  267.         if (component.type(i) == "screen") then
  268.             --prepScreen(i);
  269.         end
  270.     end
  271. end
  272.  
  273. -- Find a wireless modem
  274. function findWirelessModem()
  275.     local foundWireless = false;
  276.     for i,name in pairs(component.list()) do
  277.         for j,method in pairs(component.methods(i)) do
  278.             if (method == 'isWireless') then
  279.                 wmod = compoent.proxy(i);
  280.                 if (wmod.isWireless()) then
  281.                     wmod.closeAll();
  282.                     foundWireless = true;
  283.                     break;
  284.                 else
  285.                     wmod = {};
  286.                 end
  287.             end
  288.         end
  289.         if (foundWireless) then
  290.             break;
  291.         end
  292.     end
  293. end
  294.  
  295. function collectLocalInfo()
  296.     statuslog("Collecting local info");
  297.     local timestamp = os.clock();
  298.     ContentData = {};
  299.     for i,name in pairs(component.list()) do
  300.         local displayNames = {};
  301.         local items = {};
  302.         local p = component.proxy(i);
  303.         if (p.getInventorySize ~= nil) then
  304.             statuslog("Processing ChestTypes");
  305.             if (string.find(tostring(p.getInventorySize),"side:number") ~= nil) then
  306.                 for j=0,5,1 do
  307.                     local chestSize = nil;
  308.                     chestSize = p.getInventorySize(j);
  309.                     if (chestSize ~= nil) then
  310.                         for k=1,chestSize,1 do
  311.                             local iteminfo = nil;
  312.                             if (string.find(tostring(p.getStackInSlot),"side:number") ~= nil) then
  313.                                 iteminfo = p.getStackInSlot(j,k);
  314.                             else
  315.                                 iteminfo = p.getStackInSlot(k);
  316.                             end
  317.                             if (iteminfo) then
  318.                                 displayname = iteminfo.label;
  319.                                 if (displayname == nil) then
  320.                                     displayname = iteminfo.display_name;
  321.                                 end
  322.                                 fingerlog = iteminfo.name;
  323.                                 local amount = iteminfo.size;
  324.                                 if (amount == nil) then amount = 0; end
  325.                                 updateTable(id,displayname,amount,timestamp,"#");
  326.                             end
  327.                         end
  328.                     end
  329.                 end
  330.             else
  331.                 chestSize = p.getInventorySize();
  332.                 if (chestSize ~= nil) then
  333.                     for k=1,chestSize,1 do
  334.                         local iteminfo = nil;
  335.                         iteminfo = p.getStackInSlot(k);
  336.                         if (iteminfo) then
  337.                             displayname = iteminfo.label;
  338.                             if (displayname == nil) then
  339.                                 displayname = iteminfo.display_name;
  340.                             end
  341.                             fingerlog = iteminfo.name;
  342.                             local amount = iteminfo.size;
  343.                             if (amount == nil) then amount = 0; end
  344.                             updateTable(id,displayname,amount,timestamp,"#");
  345.                         end
  346.                     end
  347.                 end
  348.             end
  349.         end
  350.         if (p.getFluidInTank ~= nil) then
  351.             statuslog("Processing Tank");
  352.             if (string.find(tostring(p.getFluidInTank),"side:number") ~= nil) then
  353.                 for j=0,5,1 do
  354.                     local iteminfo = p.getFluidInTank(j);
  355.                     local label = "";
  356.                     local amount = 0;
  357.                     local capacity = 0;
  358.                     if (iteminfo.n ~= 0) then
  359.                         for k=1,iteminfo.n,1 do
  360.                             local label = iteminfo[k].label;
  361.                             if (label == nil) then
  362.                                 label = iteminfo[k].name;
  363.                             end
  364.                             if (label == nil) then
  365.                                 label = "Unknown";
  366.                             end
  367.                             amount = iteminfo[k].amount;
  368.                             capacity = iteminfo[k].capacity;
  369.                             if (amount > 0) then
  370.                                 updateTable(id,label,amount,timestamp,"+");
  371.                             end
  372.                         end
  373.                     end
  374.                 end
  375.             else
  376.                 local iteminfo = p.getFluidInTank();
  377.                 local label = "";
  378.                 local amount = 0;
  379.                 local capacity = 0;
  380.                 if (iteminfo.n ~= 0) then
  381.                     for k=1,iteminfo.n,1 do
  382.                         local label = iteminfo[k].label;
  383.                         if (label == nil) then
  384.                             label = iteminfo[k].name;
  385.                         end
  386.                         if (label == nil) then
  387.                             label = "Unknown";
  388.                         end
  389.                         amount = iteminfo[k].amount;
  390.                         capacity = iteminfo[k].capacity;
  391.                         if (amount > 0) then
  392.                             updateTable(id,label,amount,timestamp,"+");
  393.                         end
  394.                     end
  395.                 end
  396.             end
  397.         end
  398.         if (p.getEnergyStored ~= nil) then
  399.             statuslog("Processing Energy");
  400.             if (string.find(tostring(p.getEnergyStored),"side:number") ~= nil) then
  401.                 for j=0,5,1 do
  402.                     local energy = p.getEnergyStored(j);
  403.                     updateTable(id,"Energy",energy,timestamp,"*");
  404.                 end
  405.             else
  406.                 local energy = p.getEnergyStored();
  407.                 updateTable(id,"Energy",energy,timestamp,"*");
  408.             end
  409.         end
  410.         if (p.getGas ~= nil) then
  411.             statuslog("Processing Gas");
  412.             if (string.find(tostring(p.getGas),"side:number") ~= nil) then
  413.                 for j=0,5,1 do
  414.                     local iteminfo = p.getGas(j);
  415.                     local label = "";
  416.                     local amount = 0;
  417.                     if (iteminfo) then
  418.                         local label = iteminfo.label;
  419.                         if (label == nil) then
  420.                             label = iteminfo.name;
  421.                         end
  422.                         if (label == nil) then
  423.                             label = "Unknown";
  424.                         end
  425.                         amount = iteminfo.amount;
  426.                         if (amount > 0) then
  427.                             updateTable(id,label,amount,timestamp,"$");
  428.                         end
  429.                     end
  430.                 end
  431.             else
  432.                 local iteminfo = p.getGas();
  433.                 local label = "";
  434.                 local amount = 0;
  435.                 if (iteminfo) then
  436.                     local label = iteminfo.label;
  437.                     if (label == nil) then
  438.                         label = iteminfo.name;
  439.                     end
  440.                     if (label == nil) then
  441.                         label = "Unknown";
  442.                     end
  443.                     amount = iteminfo.amount;
  444.                     if (amount > 0) then
  445.                         updateTable(id,label,amount,timestamp,"$");
  446.                     end
  447.                 end
  448.             end
  449.         end
  450.         if (p.getItemsInNetwork ~= nil) then
  451.             statuslog("Processing ME System");
  452.             if (string.find(tostring(p.getItemsInNetwork),"side:number") ~= nil) then
  453.                 for j=0,5,1 do
  454.                     local itemarray = p.getItemsInNetwork(j);
  455.                     for j=1,itemarray.n,1 do
  456.                         if (itemarray[j].size > 0) then
  457.                             local fingerlog = itemarray[j].name;
  458.                             local displayName = itemarray[j].label;
  459.                             updateTable(id,displayName,itemarray[j].size,timestamp,"#");
  460.                         end
  461.                     end
  462.                 end
  463.             else
  464.                 local itemarray = p.getItemsInNetwork();
  465.                 for j=1,itemarray.n,1 do
  466.                     if (itemarray[j].size > 0) then
  467.                         local fingerlog = itemarray[j].name;
  468.                         local displayName = itemarray[j].label;
  469.                         updateTable(id,displayName,itemarray[j].size,timestamp,"#");
  470.                     end
  471.                 end
  472.             end
  473.         end
  474.         if (name == "xnet") then
  475.             statuslog("Processing XNet Systems");
  476.             local connectedBlocks = p.getConnectedBlocks();
  477.             for j=1,connectedBlocks.n,1 do
  478.                 local energyinfo = p.getEnergy(connectedBlocks[j].pos);
  479.                 if (energyinfo ~= nil) then
  480.                     local energy = energyinfo.stored;
  481.                     updateTable(id,"Energy",energy,timestamp,"*");
  482.                 end
  483.                 local itemarray = p.getItems(connectedBlocks[j].pos);
  484.                 if (itemarray ~= nil) then
  485.                     for k=1,itemarray.n,1 do
  486.                         if (itemarray[k].size > 0) then
  487.                             local displayName = itemarray[k].label;
  488.                             updateTable(id,displayName,itemarray[k].size,timestamp,"#");
  489.                         end
  490.                     end
  491.                 end
  492.                 local fluidarray = p.getFluids(connectedBlocks[j].pos);
  493.                 if (fluidarray ~= nil) then
  494.                     for k=1,fluidarray.n,1 do
  495.                         if (fluidarray[k].content ~= nil) then
  496.                             if (fluidarray[k].content.amount > 0) then
  497.                                 local amount = fluidarray[k].content.amount;
  498.                                 local displayName = fluidarray[k].content.label;
  499.                                 updateTable(id,displayName,amount,timestamp,"+");
  500.                             end
  501.                         end
  502.                     end
  503.                 end
  504.             end
  505.         end
  506.         statuslog("Done");
  507.     end
  508. end
  509.  
  510. function updateMonitor()
  511.     --x,y = term.getViewport();
  512.     x,y = component.gpu.getViewport();
  513.     ColumnWidth = NameLen + 7;
  514.     MaxColumn = math.floor(x / (ColumnWidth))-1;
  515.     component.gpu.setBackground(0x000000);
  516.     term.clear();
  517.     CurColumn = 0;
  518.     CurLine = 1;
  519.     term.setCursor(1,1);
  520.     component.gpu.setForeground(0xFFFFFF);
  521.     --term.setTextScale(0.5);
  522.     term.write(VersionInfo);
  523.     -- Sort by Base names
  524.     local sortedSources = {};
  525.     for n in pairs(ContentData) do
  526.         table.insert(sortedSources, n);
  527.     end
  528.     table.sort(sortedSources);
  529.     local name = "";
  530.     for i,source in ipairs(sortedSources) do
  531.         if (name ~= source) then
  532.             name = source;
  533.             CurColumn = 0;
  534.             component.gpu.setForeground(titleTextColor);
  535.             component.gpu.setBackground(titleBackColor);
  536.             term.setCursor(1,CurLine+1);
  537.             term.write(padString("Contents for "..name,x-1));
  538.             CurLine = CurLine + 2;
  539.         end
  540.         sortedTimestamps = {};
  541.         for timestamp in pairs(ContentData[source]) do
  542.             table.insert(sortedTimestamps,timestamp);
  543.         end
  544.         table.sort(sortedTimestamps);
  545.         latest = nil;
  546.         local maxn = 0;
  547.         for index in pairs(sortedTimestamps) do
  548.             maxn = maxn + 1;
  549.         end
  550.         for j=maxn,1,-1 do
  551.             if (latest == nil) then
  552.                 latest = sortedTimestamps[j];
  553.             else
  554.                 ContentData[source][sortedTimestamps[j]] = nil;
  555.             end
  556.         end
  557.         sortedItems = {};
  558.         for itemname in pairs(ContentData[source][latest]) do
  559.             table.insert(sortedItems,itemname);
  560.         end
  561.         table.sort(sortedItems);
  562.         for i in pairs(sortedItems) do
  563.             name = sortedItems[i];
  564.             count = ContentData[source][latest][name]["count"];
  565.             legend = ContentData[source][latest][name]["legend"];
  566.             max = 0;
  567.             printmon(name,count,max,legend);
  568.         end
  569.     end
  570. end
  571. function timerEvent()
  572.     statuslog("Timer Event")
  573.     updateCount = updateCount + 1;
  574.     if (updateCount >= 3) then
  575.         updateCount = 0;
  576.         ContentData = {};
  577.     end
  578.     collectLocalInfo();
  579.     if (wmod) then
  580.         if (isMain == false) then
  581.             wmod.transmit(mainChannel,1,ContentData);
  582.         end
  583.     end
  584.     --if (updateCount == 2) then
  585.         updateMonitor();
  586.     --end
  587.     wirelessEventCount = 0;
  588. end
  589. -- This is the main section of the script
  590.  
  591. findScreen();
  592. checkDepth();
  593. findWirelessModem();
  594.  
  595. if (isMain == true) then
  596.     if (type(wmod.isWireless) == "function") then
  597.         wmod.open(mainChannel);
  598.     else
  599.         statuslog("You don't have a wireless modem, and this is set as the main computer");
  600.     end
  601. end
  602.  
  603. ContentData = {};
  604. local timerUpdate = event.timer(UpdateIntervalSeconds,timerEvent,math.huge);
  605. local clocktimer = event.timer(1,printclock,math.huge);
  606. local wirelessEventCount = 0;
  607. -- Perform Initial Collection and Update the Monitor
  608. collectLocalInfo();
  609. updateMonitor();
  610.  
  611. -- Main program loop
  612. continue = true;
  613. statuslog("Running main loop")
  614. while continue do
  615.     --continue = false;
  616.     local eventname, param1, param2, param3, param4, param5 = event.pull();
  617.     if (eventname == nil) then eventname = "Unknown"; end
  618.     statuslog("Received event:"..eventname);
  619.     if (eventname == "interrupted") then
  620.         continue = false;
  621.     end
  622.     if (eventname == "timer") then
  623.         if (param1 == timerUpdate) then
  624.             updateCount = updateCount + 1;
  625.             if (updateCount >= 3) then
  626.                 updateCount = 0;
  627.                 ContentData = {};
  628.             end
  629.             collectLocalInfo();
  630.             if (wmod) then
  631.                 if (isMain == false) then
  632.                     wmod.transmit(mainChannel,1,ContentData);
  633.                 end
  634.             end
  635.             updateMonitor();
  636.             wirelessEventCount = 0;
  637.             -- timerUpdate = os.startTimer(5);
  638.             -- timerUpdate = event.timer(60,timerEvent);
  639.         end
  640.     end
  641.     if (eventname == "modem_message") then
  642.         if (isMain == true) then
  643.             wirelessEventCount = wirelessEventCount + 1;
  644.             for source,data in pairs(param4) do
  645.                 if (ContentData[source] == nil) then
  646.                     ContentData[source] = {};
  647.                 end
  648.             ContentData[source] = param4[source];
  649.         end
  650.             if (wirelessEventCount >= 10) then
  651.                 timerUpdate = os.startTimer(1);
  652.             end
  653.         end
  654.     end
  655.     if (eventname == "touch") or (eventname == "monitor_resize") then
  656.         statuslog("Updating the Monitor");
  657.         updateMonitor();
  658.     end
  659.     if (eventname == "component_added") or (eventname == "component_removed") then
  660.         collectLocalInfo();
  661.         updateMonitor();
  662.     end
  663. end
  664. event.cancel(timerUpdate);
  665. event.cancel(clocktimer);
  666. term.clear();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement