北大侠客行MUD论坛

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

关于wait.regexp使得匹配后该行保持有效的问题。

[复制链接]
发表于 2010-9-4 08:58:21 | 显示全部楼层 |阅读模式
我在看http://blog.csdn.net/suxiaojack/archive/2008/10/10/3042706.aspx文章的时候,里面提到了
1、修改wait.regexp使得匹配后该行保持有效,触发器仍旧为临时触发(一劳永逸。)

我想问问这个如何修改呢?
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
发表于 2010-9-4 09:55:59 | 显示全部楼层
function regexp (regexp, timeout)
  local id = "wait_trigger_" .. GetUniqueNumber ()
  threads [id] = assert (coroutine.running (), "Must be in coroutine")

  check (AddTriggerEx (id, regexp,
            "-- added by wait.regexp",  
            trigger_flag.Enabled + trigger_flag.RegularExpression +
            trigger_flag.Temporary + trigger_flag.Replace, -- + 注意这个
            --trigger_flag.OneShot, -- 把此处注释就可以了,使得匹配后该行保持有效,触发器仍旧为临时触发
            custom_colour.NoChange,
            0, "",  -- wildcard number, sound file name
            "wait.trigger_resume",
            12, 100))  -- send to script (in case we have to delete the timer)

  -- if timeout specified, also add a timer
  if timeout and timeout > 0 then
    local hours, minutes, seconds = convert_seconds (timeout)

    -- if timer fires, it deletes this trigger
    check (AddTimer (id, hours, minutes, seconds,
                   "DeleteTrigger ('" .. id .. "')",
                   timer_flag.Enabled + timer_flag.OneShot +
                   timer_flag.Temporary + timer_flag.Replace,
                   "wait.timer_resume"))

    check (SetTimerOption (id, "send_to", "12"))  -- send to script

    -- if trigger fires, it should delete the timer we just added
    check (SetTriggerOption (id, "send", "DeleteTimer ('" .. id .. "')"))  

  end -- if having a timeout

  return coroutine.yield ()  -- return line, wildcards
end -- function regexp

[ 本帖最后由 tianheng 于 2010-9-4 09:57 AM 编辑 ]
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-28 09:18 PM , Processed in 0.011605 second(s), 14 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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