|
function ReadAndWriteMapInfo()--读取连接点方法
local file=io.open(mainPath.."Envir\\MapInfo.txt","r")--mainPath代表服务端根目录
local tab={}
repeat
local str=file:read("*l")
if(str~=nil and str~="") then
local map1,x1,y1,map2,x2,y2=string.match(str,"^%s*(%w+)%s+(%d+)%s*,%s*(%d+)%s+%-%s*>%s+(%w+)%s+(%d+)%s*,%s*(%d+)%s*;*.*$")
if(y2) then
map1=string.upper(map1)
map2=string.upper(map2)
local sign=0
if(not tab[map2]) then
tab[map2]={}
else
for i=1,#tab[map2]do
if(i%5==1) then
if(tab[map2][i]==map1) then
sign=1
end
end
end
end
if(sign==0) then
table.insert(tab[map2],map1)
table.insert(tab[map2],x1)
table.insert(tab[map2],y1)
table.insert(tab[map2],x2)
table.insert(tab[map2],y2)
end
end
end
until(not str)
file:close()
return tab
end |
|