ppkas 发表于 2018-3-22 13:21:25

借花献佛 发个自动区域行走

本帖最后由 ppkas 于 2018-3-22 05:25 AM 编辑

----区域信息处理-------------------------------------------------------------
areas={      "中原","西湖梅庄","曲阜","信阳","泰山","长江南岸","长江","长江北岸","黄河南岸","黄河北岸",
                "嘉兴","泉州","江州","牙山","临安府","西湖","福州","南昌","镇江","苏州","归云庄","小山村","张家口",
                "麒麟村","大理城中","昆明","平西王府","桃源","岳阳","成都","建康府南城","建康府北城","北京","康亲王府",
                "天坛","紫禁城","洛阳","灵州","晋阳","日月神教","神龙岛","襄阳","丝绸之路","长安","扬州","杀手帮",
                "丐帮","岳王墓","姑苏慕容","桃花岛","峨嵋","天龙寺","武当山","华山","全真","古墓","少林寺","白驼山",
                "星宿","明教","灵鹫","凌霄城","大轮寺","兰州","无量山","峨眉后山","杭州提督府","天地会"
                }

get_place = function(str)
local place={}
for i=1,table.getn(areas) do
   str_l=string.len(areas)
   if areas==string.sub(str,1,str_l) then
      place.area=areas   -----区域名称
      place.room=string.sub(str,str_l+1,string.len(str))      -----房间名称
         SetVariable("goto",place.area)
         SetVariable("gotoroom",place.room)
      break
   end
end
return place
end

----区域自动行走---------------------------------------------------------------------------
function cnarea(area)
    local dir_map = {
      ["中原"] = "xuchang",["信阳"] = "xinyang",["泰山"] = "taishan",["长江南岸"] = "cjnanwest",["长江"] = "cjnaneast",
                ["长江北岸"] = "cjbeiwest",["黄河南岸"] = "hhndk",["黄河北岸"] = "huanghebeian01",["西湖梅庄"] = "西湖梅庄",["嘉兴"] = "jiaxing",
                ["泉州"] = "quanzhou",["江州"] = "jiangzhou",["牙山"] = "yashan",["临安府"] = "hangzhou",["西湖"] = "hangzhou",
                ["福州"] = "fuzhou",["南昌"] = "nanchang",["曲阜"] = "qufu",["镇江"] = "zhenjiang",["苏州"] = "suzhou",
                ["归云庄"] = "guiyunzhuang",["小山村"] = "xiaocun",["张家口"] = "zhangjiakou",["麒麟村"] = "qlctdm",["大理城中"] = "dali",
                ["昆明"] = "kunming",["平西王府"] = "pingxiwang",["桃源"] = "taoyuan",["岳阳"] = "yueyang",["成都"] = "chengdu",
                ["建康府南城"] = "jiankangchaoyangmen",["建康府北城"] = "jiankangqingliangmen",["北京"] = "beijing",["康亲王府"] = "kangqinwangfu",["天坛"] = "",
                ["紫禁城"] = "zijincheng",["洛阳"] = "luoyang",["灵州"] = "lingzhou",["晋阳"] = "jinyang",["日月神教"] = "riyue",
                ["神龙岛"] = "sld",["襄阳"] = "xy",["丝绸之路"] = "sichou",      ["长安"] = "changan",["扬州"] = "yangzhou",
                ["杀手帮"] = "shashouguangchang",["丐帮"] = "andao",["岳王墓"] = "yuewangmu",["姑苏慕容"] = "yanziwu",["桃花岛"] = "taohua",
                ["峨嵋"] = "emei",["天龙寺"] = "tl",["武当山"] = "wd",["华山"] = "hs",["全真"] = "qz",
                ["古墓"] = "gm",["少林寺"] = "sl",["白驼山"] = "bt",["星宿"] = "xx",["凌霄城"] = "lingxiao",
                ["大轮寺"] = "dalunsi",["兰州"] = "lanzhou",["无量山"] = "wuliang",["杭州提督府"] = "tidufu",
                ["天地会"] = "",["峨眉后山"] = "",
      -- ...
                                        }
    return dir_map
end
-------------------------
使用: local place = cnarea(GetVariable("goto"))
Execute("gt "..place)
北大侠客行MUD,中国最好的MUD

songtao 发表于 2018-3-22 13:53:37

呃...我的mush还没有解决坐车报错的问题...

man 发表于 2018-3-22 22:55:26

这个区域分割比较怪异,为啥不用正则?


回复 1# ppkas

ppkas 发表于 2018-3-23 09:05:58

可以有很多实现方法啊,这个是别人贴出来的函数,我拿来用 然后修改修改
用正则也可以的,string.find string.match 等都可以实现功能。

jhzg 发表于 2018-8-25 14:02:14

学习学习,还在研究开窗口
页: [1]
查看完整版本: 借花献佛 发个自动区域行走