|
本帖最后由 joyce@tj 于 2021-1-10 23:38 编辑
感觉更简洁一点,看着舒服点。。。
- Bag = {}
- weaponUsave = {}
- function checkBags(func)
- tmp.hook_checkBags = func
- local cmd = 'id;i;look bei nang;uweapon'
- exe(cmd)
- return checkBags1()
- end
- function checkBags1()
- local timeout = 1.5
- wait.make(function()
- local l_tmp = ''
- -- 二十颗川贝内息丸(Chuanbei wan)
- -- 十九颗蝉蜕金疮药(Chantui yao)
- -- 十九颗黄芪内息丹(Huangqi dan)
- _,w = wait.regexp ("^(> )*(你身上携带物品的别称如下\\(\\D+\\):|你目前没有自己的私有装备。|你身上带着(\\D*)件东西\\(负重 (\\d*)\\.\\d*\\%\\):|(□| )(\\D+)(锭|两|张|文|颗)(白银|黄金|壹仟两银票|铜钱|川贝内息丸|蝉蜕金疮药|黄芪内息丹|百花丸|大还丹)\\((\\D+)\\)|\\d*:(\\D*) = (\\D*)|你目前已经拥有了(\\D*)件私有装备:(\\D*)。)$", timeout)
- if w then l_tmp = w[2] end
- if l_tmp ~= '' then
- if string.find(l_tmp,'你身上携带物品的别称如下') then
- -- 初始化背包
- Bag = {}
- return checkBags1()
- elseif string.find(l_tmp,'你身上带着') then
- local s = trans(w[3]) -- 道具数量
- local t = tonumber(w[4]) -- 负重
- -- 负重
- Bag["ENCB"] = t
- return checkBags1()
- elseif string.find(l_tmp,'两白银') or string.find(l_tmp,'锭黄金') or string.find(l_tmp,'文铜钱') or string.find(l_tmp,'张壹仟两银票')
- or string.find(l_tmp,'颗川贝内息丸') or string.find(l_tmp,'颗蝉蜕金疮药') or string.find(l_tmp,'颗黄芪内息丹') or string.find(l_tmp,'颗百花丸') or string.find(l_tmp,'颗大还丹') then
- -- (□| )(\\D+)(锭|两|张|文|颗)(白银|黄金|壹仟两银票|铜钱|川贝内息丸|蝉蜕金疮药|黄芪内息丹|百花丸|大还丹)\\((\\D+)\\) -- 5
- local n = trans(Trim(w[6])) -- 数量
- local id = string.lower(Trim(w[9])) -- id
- local name = w[8] -- 名字
- Bag[name] = {}
- Bag[name].id = id
- Bag[name].cnt = n
- return checkBags1()
- elseif string.find(l_tmp,' = ') then
- -- \\d*:(\\D*) = (\\D*)
- -- 10
- local name = Trim(w[10])
- local id = w[11]
- if not Bag[name] then Bag[name] = {} end
- local set = {}
- local cnt = 0
- if string.find(id, ",") then
- set = utils.split(id,',')
- id = set[1]
- for k,v in ipairs(set) do
- if string.len(Trim(v))> cnt then
- Bag[name].id = Trim(v)
- cnt = string.len(Trim(v))
- end
- end
- else
- Bag[name].id = Trim(id)
- end
-
- if Bag[name].cnt then
- Bag[name].cnt = Bag[name].cnt + 1
- else
- Bag[name].cnt = 1
- end
- return checkBags1()
- elseif string.find(l_tmp,'你目前已经拥有了') then
- -- 你目前已经拥有了(\\D*)件私有装备:(\\D*)。
- local t = Trim(w[13])
- local s = utils.split(t,',')
- -- tprint(s)
- for p,q in pairs(s) do
- if string.find(q,'⊕') then
- q = string.sub(q,3,-1)
- end
- -- print(q)
- weaponUsave[q] = {}
- end
- return hook(tmp.hook_checkBags)
- elseif l_tmp == '你目前没有自己的私有装备。' then
- return hook(tmp.hook_checkBags)
- end
- end
- -- 超时
- print('checkBags 超时!')
- return checkBags(tmp.hook_checkBags)
- end)
- end
复制代码 |
评分
-
2
查看全部评分
-
|