mirror of
https://github.com/LDDestroier/CC/
synced 2025-01-19 13:42:54 +00:00
Reduced amount of new fs.open()'s
This commit is contained in:
parent
714da7ee03
commit
4e0369e7d2
14
disknet.lua
14
disknet.lua
@ -157,18 +157,21 @@ disknet.receive = function(channel)
|
|||||||
local output, contents
|
local output, contents
|
||||||
local doRewrite = false
|
local doRewrite = false
|
||||||
|
|
||||||
while true do
|
|
||||||
loadFList()
|
loadFList()
|
||||||
|
|
||||||
|
while true do
|
||||||
for i = 1, #fList do
|
for i = 1, #fList do
|
||||||
contents = fList[i].readAll()
|
contents = fList[i].readAll()
|
||||||
if contents ~= "" then
|
if contents ~= "" then
|
||||||
contents = textutils.unserialize(contents)
|
fList[i].close()
|
||||||
|
fList[i] = fs.open(pList[i], "r")
|
||||||
|
contents = textutils.unserialize(fList[i].readAll())
|
||||||
if type(contents) == "table" then
|
if type(contents) == "table" then
|
||||||
if contents[1] then
|
if contents[1] then
|
||||||
if not output then
|
if not output then
|
||||||
for look = 1, #contents do
|
for look = 1, #contents do
|
||||||
if (contents[look].uniqueID ~= uniqueID) and (not msgCheckList[contents[look].messageID]) then
|
if (contents[look].uniqueID ~= uniqueID) and (not msgCheckList[contents[look].messageID]) then
|
||||||
if getTime() - (contents[look].time or 0) <= 0.01 then
|
if getTime() - (contents[look].time or 0) <= 0.001 then
|
||||||
msgCheckList[contents[look].messageID] = true
|
msgCheckList[contents[look].messageID] = true
|
||||||
output = {}
|
output = {}
|
||||||
for k,v in pairs(contents[look]) do
|
for k,v in pairs(contents[look]) do
|
||||||
@ -183,7 +186,7 @@ disknet.receive = function(channel)
|
|||||||
-- delete old msesages
|
-- delete old msesages
|
||||||
doRewrite = false
|
doRewrite = false
|
||||||
for t = #contents, 1, -1 do
|
for t = #contents, 1, -1 do
|
||||||
if getTime() - (contents[t].time or 0) > 0.01 then
|
if getTime() - (contents[t].time or 0) > 0.001 then
|
||||||
msgCheckList[contents[t].messageID] = nil
|
msgCheckList[contents[t].messageID] = nil
|
||||||
table.remove(contents, t)
|
table.remove(contents, t)
|
||||||
doRewrite = true
|
doRewrite = true
|
||||||
@ -205,9 +208,6 @@ disknet.receive = function(channel)
|
|||||||
if output then
|
if output then
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
for i = 1, #fList do
|
|
||||||
fList[i].close()
|
|
||||||
end
|
|
||||||
os.queueEvent("")
|
os.queueEvent("")
|
||||||
os.pullEvent("")
|
os.pullEvent("")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user