北大侠客行MUD论坛

 找回密码
 注册
搜索
热搜: 新手 wiki 升级
查看: 4361|回复: 3

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

[复制链接]
发表于 2012-10-6 15:53:31 | 显示全部楼层 |阅读模式
本帖最后由 littleknife 于 2012-10-6 04:00 PM 编辑
  1. hubiao.robberIndex={"yellow","white","cyan","blue","red","lime","magenta","green",}
  2. ----丐帮white,武当white,桃花cyan,星宿blue,全真red,少林lime,
复制代码


  1. addtri("hubiao_rbinfo","^.*劫匪\\("..hubiao.Upper_playerid.."'s robber\\)\\w*","q_hubiao","hubiao.rbinfo")
复制代码
  1. hubiao.rbinfo=function(name, line, wildcards, styles)
  2.   col = string.find (line, "劫匪")
  3.   if not col then
  4. print("::抓取失败::")
  5.     return
  6.   end
  7.   style = GetStyle (styles, col)
  8.   robberColor=RGBColourToName (style.textcolour)
  9.   ----print ("劫匪的颜色:", robberColor)
  10.   table.insert(hubiao.robberColor,robberColor)
  11.   ------------------------------------------
  12.   if simTableIndex(robberColor,hubiao.robberIndex)==-1 then
  13.   table.insert(hubiao.robberIndex,robberColor)
  14.   end
  15.   ------------------------------------------
  16. end

复制代码

  1. function GetStyle (styleRuns, wantedColumn)
  2. local currentColumn = 1
  3.    -- check arguments
  4.    assert (type (styleRuns) == "table",
  5.            "First argument to GetStyle must be table of style runs")
  6.    assert (type (wantedColumn) == "number" and wantedColumn >= 1,
  7.            "Second argument to GetStyle must be column number to find")
  8.    -- go through each style
  9.    for item, style in ipairs (styleRuns) do
  10.      local position = wantedColumn - currentColumn + 1  -- where letter is in style
  11.      currentColumn = currentColumn + style.length       -- next style starts here
  12.      if currentColumn > wantedColumn then  -- if we are within this style
  13.         return style, string.sub (style.text, position, position), item  -- done
  14.      end -- if found column
  15.    end -- for each style
  16.    -- if not found: result is nil
  17. end -- function GetStyle
复制代码

  1. addtri=function(triname,trimatch,trigroup,triscript,triflag,trisequence)
  2. if triflag==nil or triflag=="" then triflag=flag_base end
  3. if trisequence==nil then trisequence=10 end
  4. trireturnvalue=AddTriggerEx(triname, trimatch, "", triflag, -1, 0, "",  triscript, 0, trisequence)
  5. SetTriggerOption(triname,"group",trigroup)
  6. return trireturnvalue
  7. end
复制代码


  1. function simTableIndex(str,list)
  2.   for i,value in pairs(list)  do
  3.     if (value==str) then
  4.       return i
  5.     end
  6.   end
  7.   return -1
  8. end
复制代码


北大侠客行MUD,中国最好的MUD
北大侠客行Mud(pkuxkx.com),最好的中文Mud游戏!
发表于 2012-10-6 16:06:13 | 显示全部楼层
怪不得见你这两天老丢镖了,顶一个
北大侠客行Mud(pkuxkx.com),最好的中文Mud游戏!
发表于 2012-10-6 18:43:14 | 显示全部楼层
存档,以后来学习!
北大侠客行Mud(pkuxkx.com),最好的中文Mud游戏!
发表于 2012-10-6 18:50:15 | 显示全部楼层
看不懂。。。
北大侠客行Mud(pkuxkx.com),最好的中文Mud游戏!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|北大侠客行MUD ( 京ICP备16065414号-1 )

GMT+8, 2024-11-28 12:27 PM , Processed in 0.015371 second(s), 14 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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