|
本帖最后由 kkfromch@tj 于 2019-3-27 14:30 编辑
- --不废话,直接上code!
- lujing.lua——
- -----------------------------------------------出梅林-------------------------------------
- [b]function mlOutt()[/b]
- tmp.cnt=0
- exe('look')
- wait.make(function()
- wait.time(2.5)
- if flag.find==1 then return end
- exe('n')
- return mloutdo()
- end)
- end
- function mloutdo()
- fastLocate()
- wait.make(function()
- wait.time(1)
- if flag.find==1 then return end
- if locl.room~='梅林' then
- return path_consider()
- else
- return mlOut()
- end
- end)
- end
- function mlOut()
- tmp.way = "north"
- tmp.ml = "out"
- exe('w;e;n')
- fastLocate()
- return checkWait(wayMl,0.5)
- end
- function wait_seconds()
- wait.make(function()
- wait.time(5)
- return wayMl()
- end)
- end
- function wayMl()
- tmp.cnt=tmp.cnt+1
- if tmp.cnt>50 then
- tmp.cnt=0
- return wait_seconds()
- end
- local ways = {
- ["north"] = "east",
- ["east"] = "south",
- ["south"] = "west",
- ["west"] = "north",
- }
- local wayt = {
- ["north"] = "west",
- ["east"] = "north",
- ["south"] = "east",
- ["west"] = "south",
- }
- if not tmp.way or not ways[tmp.way] then
- tmp.way = 'south'
- end
- if locl.room=="青石板大路" then
- if tmp.ml and tmp.ml=="in" then
- return wayMlOver()
- else
- tmp.way = "north"
- exe(tmp.way)
- fastLocate()
- return checkWait(wayMl,0.5)
- end
- end
- if locl.room=="小路" then
- if tmp.ml and tmp.ml=="out" then
- print('出来了')
- exe('n')
- return wayMlOver()
- else
- tmp.way = "south"
- exe('south;south')
- locate()
- return checkWait(wayMl,0.5)
- end
- end
- if locl.room~="小路" and locl.room~="青石板大路" and locl.room~="梅林" then
- return wayMlOver()
- end
- tmp.way = ways[tmp.way]
- --[[while not locl.exit[tmp.way] do
- Note(tmp.way)
- tmp.way = wayt[tmp.way]
- end]]
- repeat
- if not locl.exit[tmp.way] then
- Note(tmp.way)
- tmp.way = wayt[tmp.way]
- end
- until(locl.exit[tmp.way])
- --[[if not locl.exit[tmp.way] then
- Note(tmp.way)
- tmp.way = wayt[tmp.way]
- end
- if not locl.exit[tmp.way] then
- Note(tmp.way)
- tmp.way = wayt[tmp.way]
- end
- if not locl.exit[tmp.way] then
- Note(tmp.way)
- tmp.way = wayt[tmp.way]
- end
- if not locl.exit[tmp.way] then
- Note(tmp.way)
- tmp.way = wayt[tmp.way]
- end]]
- exe(tmp.way)
- fastLocate()
- return checkWait(wayMl,0.5)
- end
- function wayMlOver()
- return path_consider()
- --return walk_wait()
- end
- -------------------------------------------------------------------------------------------
- [b]function path_consider()[/b]
- local l_sour,l_dest,l_path,l_way
- local l_where=locl.area .. locl.room
- sour.rooms={}
- dest.rooms={}
- if sour.id and map.rooms[sour.id].name ~= locl.room then
- sour.id = nil
- end
- if not sour.id and road.id and map.rooms[road.id] and map.rooms[road.id].name == locl.room then
- sour.id = road.id
- end
- if sour.id == nil then
- sour.room=locl.room
- sour.area=locl.area
- sour.rooms=getRooms(sour.room,sour.area)
- end
- if dest.id == nil then
- dest.rooms=getRooms(dest.room,dest.area)
- end
- if sour.id ~= nil then
- chats_locate('定位系统:从【'.. sour.id ..'】出发!')
- else
- chats_locate('定位系统:从【'.. sour.area .. sour.room ..'】出发!')
- if sour.room=="观星台" then
- exe('jump down')
- end
- if table.getn(sour.rooms)==0 then
- if locl.room=='小木筏' then
- return toSldHua()
- elseif locl.room=='泉水中' then
- exe('tiao out;tiao out')
- --quick_locate=0
- return checkWait(goContinue,0.3)
- elseif locl.room=='水潭' then
- exe('pa up')
- --quick_locate=0
- return checkWait(goContinue,0.3)
- else
- if locl.room_relation=='九老洞九老洞' or locl.room_relation=="不知道哪里九老洞 不知道哪里 九老洞" then
- exe('drop fire;leave;leave;leave;leave;leave;leave;out;ne;ed;ne;ed')
- --quick_locate=0
- return checkWait(goContinue,0.3)
- end
- if locl.room_relation=='西湖边↙|白堤柳浪闻莺西湖边' then
- exe('sw')
- --quick_locate=0
- return checkWait(goContinue,0.3)
- end
- [color=Blue] if locl.room=='梅林' then
- --quick_locate=0
- exe('n')
- return mlOutt()
- end[/color]--[color=Red]就添加这个就行了![/color]
- if locl.room=='渔船' then
- exe('out;w;s;out;w;s;out;w;s')
- --quick_locate=0
- return checkWait(goContinue,0.3)
- end
- if locl.room_relation~='' then
- chats_locate('定位系统:没有归属地的房间加入了room_relative,【可以尝试定位没有归属地的房间】','LimeGreen')
- --这里可以尝试定位没有归属地的房间
- end
- chats_locate('定位系统:地图系统无此地点【'..locl.area .. locl.room ..'】资料,随机移动寻找确切定位点!','red')
- exe('stand;leave')
- exe(locl.dir)
- return checkWait(goContinue,0.2)
- end
- end
- if table.getn(sour.rooms)>1 and sour.id~='city/jiangbei' then ---------------------------------------------------------------------------------------------------
- chats_locate('定位系统:进入第一个同名房间判断【'..sour.room..'】了!','LimeGreen')
- if locl.room_relation~='' then
- chats_locate('定位系统:房间关系为【'..locl.room_relation..'】','LimeGreen')
- end
- for i=1,table.getn(sour.rooms) do
- if ( locl.room_relation~='' and map.rooms[sour.rooms[i]].room_relative == locl.room_relation) then
- chats_locate('定位系统:尝试精确定位!','LimeGreen')
- sour.id=sour.rooms[i]
- return check_halt(path_consider)
- --return go(road.act,dest.area,dest.room,sour.rooms[i])
- end
- end
- for p in pairs(locl.id) do
- local l_cnt = 0
- local l_id
- for k,v in pairs(sour.rooms) do
- local l_corpse
- if string.find(p,"的尸体") then
- l_corpse = del_string(p,"的尸体")
- else
- l_corpse = p
- end
- if map.rooms[v] and map.rooms[v].objs and (map.rooms[v].objs[p] or map.rooms[v].objs[l_corpse]) then
- l_cnt = l_cnt + 1
- l_id = v
- end
- end
- if l_cnt == 1 then
- return go(road.act,dest.area,dest.room,l_id)
- end
- end
- if not roomMaze[l_where] then
- for p in pairs(locl.exit) do
- local l_cnt = 0
- local l_id
- for i=1,table.getn(sour.rooms) do
- if map.rooms[sour.rooms[i]] and map.rooms[sour.rooms[i]].ways and map.rooms[sour.rooms[i]].ways[p] then
- l_cnt = l_cnt + 1
- l_id = sour.rooms[i]
- end
- end
- if l_cnt == 1 then
- return go(road.act,dest.area,dest.room,l_id)
- end
- end
- end
- end
- if roomMaze[l_where] then
- if type(roomMaze[l_where])=='function' then
- l_way = roomMaze[l_where]()
- else
- l_way = roomMaze[l_where]
- end
- end
- if l_way then
- exe(l_way)
- exe("yun jingli")
- chats_locate('定位系统:地图系统此地点【'..locl.area .. locl.room ..'】无简单路径,移动寻找确切定位点!','red')
- return checkWait(goContinue,0.5)
- end
- if table.getn(sour.rooms)>1 and sour.id~='city/jiangbei' then -------------------------------------------------------------------------
- if locl.room_relation~='' then --触发器获取到房间相对关系字符串
- for i=1,table.getn(sour.rooms) do
- if (locl.room_relation~='' and map.rooms[sour.rooms[i]].room_relative == locl.room_relation) then
- chats_locate('定位系统:精确定位房间id为:【'..sour.rooms[i]..'】','LimeGreen')
- sour.id=sour.rooms[i]
- return check_halt(path_consider)
- --return go(road.act,dest.area,dest.room,sour.rooms[i])
- else
- chats_locate('定位系统:地图系统此地点【'..locl.area .. locl.room ..'】无法精确定位,随机移动!','red')
- exe('stand;leave')
- exe(locl.dir)
- return checkWait(goContinue,0.5)
- end
- end
- else
- chats_locate('定位系统:地图系统此地点【'..locl.area .. locl.room ..'】存在不止一处,随机移动寻找确切定位点!','red')
- exe('stand;leave')
- exe(locl.dir)
- return checkWait(goContinue,0.5)
- end
- end
- end
- if dest.id == nil and table.getn(dest.rooms)==0 then
- Note('Path Consider GetRooms Error!')
- return false
- end
- path_create()
- return check_halt(path_start)
- end
- -------------
- [b]最后,rooms.lua[/b]
- Room {
- id = "meizhuang/plum_maze",
- name = "梅林",
- ways = {
- ["#mlOutt"] = "meizhuang/road2",
- --["#inmz"] = "meizhuang/road3",
- },
- }
复制代码 |
|