mirror of
				https://github.com/LDDestroier/CC/
				synced 2025-10-30 23:12: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) | ||||
| 	local valid, grr = checkValidChannel(channel) | ||||
| 	if valid or not channel then | ||||
| 	 | ||||
|  | ||||
| 		local output, contents | ||||
| 		local doRewrite = false | ||||
| 		 | ||||
|  | ||||
| 		loadFList() | ||||
|  | ||||
| 		while true do | ||||
| 			loadFList() | ||||
| 			for i = 1, #fList do | ||||
| 				contents = fList[i].readAll() | ||||
| 				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 contents[1] then | ||||
| 							if not output then | ||||
| 								for look = 1, #contents do | ||||
| 									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 | ||||
| 											output = {} | ||||
| 											for k,v in pairs(contents[look]) do | ||||
| @@ -179,11 +182,11 @@ disknet.receive = function(channel) | ||||
| 									end | ||||
| 								end | ||||
| 							end | ||||
| 							 | ||||
|  | ||||
| 							-- delete old msesages | ||||
| 							doRewrite = false | ||||
| 							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 | ||||
| 									table.remove(contents, t) | ||||
| 									doRewrite = true | ||||
| @@ -205,14 +208,11 @@ disknet.receive = function(channel) | ||||
| 			if output then | ||||
| 				break | ||||
| 			else | ||||
| 				for i = 1, #fList do | ||||
| 					fList[i].close() | ||||
| 				end | ||||
| 				os.queueEvent("") | ||||
| 				os.pullEvent("") | ||||
| 			end | ||||
| 		end | ||||
| 		 | ||||
|  | ||||
| 		if contents then | ||||
| 			return output.message, output.channel, output.id, output.time | ||||
| 		else | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 LDDestroier
					LDDestroier