littleknife 发表于 2012-10-6 15:53:31

学习笔记之颜色判定抓取信息的方法(MUSH)

本帖最后由 littleknife 于 2012-10-6 04:00 PM 编辑

hubiao.robberIndex={"yellow","white","cyan","blue","red","lime","magenta","green",}
----丐帮white,武当white,桃花cyan,星宿blue,全真red,少林lime,



addtri("hubiao_rbinfo","^.*劫匪\\("..hubiao.Upper_playerid.."'s robber\\)\\w*","q_hubiao","hubiao.rbinfo")

hubiao.rbinfo=function(name, line, wildcards, styles)
col = string.find (line, "劫匪")
if not col then
print("::抓取失败::")
    return
end
style = GetStyle (styles, col)
robberColor=RGBColourToName (style.textcolour)
----print ("劫匪的颜色:", robberColor)
table.insert(hubiao.robberColor,robberColor)
------------------------------------------
if simTableIndex(robberColor,hubiao.robberIndex)==-1 then
table.insert(hubiao.robberIndex,robberColor)
end
------------------------------------------
end



function GetStyle (styleRuns, wantedColumn)
local currentColumn = 1
   -- check arguments
   assert (type (styleRuns) == "table",
         "First argument to GetStyle must be table of style runs")
   assert (type (wantedColumn) == "number" and wantedColumn >= 1,
         "Second argument to GetStyle must be column number to find")
   -- go through each style
   for item, style in ipairs (styleRuns) do
   local position = wantedColumn - currentColumn + 1-- where letter is in style
   currentColumn = currentColumn + style.length       -- next style starts here
   if currentColumn > wantedColumn then-- if we are within this style
      return style, string.sub (style.text, position, position), item-- done
   end -- if found column
   end -- for each style
   -- if not found: result is nil
end -- function GetStyle


addtri=function(triname,trimatch,trigroup,triscript,triflag,trisequence)
if triflag==nil or triflag=="" then triflag=flag_base end
if trisequence==nil then trisequence=10 end
trireturnvalue=AddTriggerEx(triname, trimatch, "", triflag, -1, 0, "",triscript, 0, trisequence)
SetTriggerOption(triname,"group",trigroup)
return trireturnvalue
end



function simTableIndex(str,list)
for i,value in pairs(list)do
    if (value==str) then
      return i
    end
end
return -1
end

北大侠客行MUD,中国最好的MUD

when 发表于 2012-10-6 16:06:13

怪不得见你这两天老丢镖了,顶一个

aomei 发表于 2012-10-6 18:43:14

存档,以后来学习!

flauto 发表于 2012-10-6 18:50:15

看不懂。。。yct30yct30yct30
页: [1]
查看完整版本: 学习笔记之颜色判定抓取信息的方法(MUSH)