mirror of
				https://github.com/LDDestroier/CC/
				synced 2025-10-31 15:32:59 +00:00 
			
		
		
		
	Reduced amount of new fs.open()'s
This commit is contained in:
		
							
								
								
									
										22
									
								
								disknet.lua
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								disknet.lua
									
									
									
									
									
								
							| @@ -153,22 +153,25 @@ end | |||||||
| disknet.receive = function(channel) | disknet.receive = function(channel) | ||||||
| 	local valid, grr = checkValidChannel(channel) | 	local valid, grr = checkValidChannel(channel) | ||||||
| 	if valid or not channel then | 	if valid or not channel then | ||||||
| 	 |  | ||||||
| 		local output, contents | 		local output, contents | ||||||
| 		local doRewrite = false | 		local doRewrite = false | ||||||
| 		 |  | ||||||
|  | 		loadFList() | ||||||
|  |  | ||||||
| 		while true do | 		while true do | ||||||
| 			loadFList() |  | ||||||
| 			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 | ||||||
| @@ -179,11 +182,11 @@ disknet.receive = function(channel) | |||||||
| 									end | 									end | ||||||
| 								end | 								end | ||||||
| 							end | 							end | ||||||
| 							 |  | ||||||
| 							-- 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,14 +208,11 @@ 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 | ||||||
| 		end | 		end | ||||||
| 		 |  | ||||||
| 		if contents then | 		if contents then | ||||||
| 			return output.message, output.channel, output.id, output.time | 			return output.message, output.channel, output.id, output.time | ||||||
| 		else | 		else | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 LDDestroier
					LDDestroier