龙族引擎

 立即注册
搜索
查看: 3137|回复: 1

从mapinfo中读取所有地图连接点

[复制链接]

2

主题

2

帖子

0

积分

新手

Rank: 1

积分
0
发表于 2018-10-16 10:19:07 | 显示全部楼层 |阅读模式
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
回复

使用道具 举报

0

主题

27

帖子

1

积分

新手

Rank: 1

积分
1
发表于 2019-9-3 08:15:24 | 显示全部楼层
真的很有用,谢谢啦!












海参的价格  shihaishen.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|龙族引擎 ( 备案信息 )

GMT+8, 2024-4-23 19:55 , Processed in 0.044466 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表