|
楼主 |
发表于 2017-4-7 00:55:49
|
显示全部楼层
二、说一下触发器的设置
以送信的lua里面一段为例:
- DeleteTriggerGroup("songxin2_check")
- DeleteTriggerGroup("songxin2_killer")
- create_trigger_t('songxin_ask1',"^>*\\s*你向褚万里打听",'','songxin_ask')
- create_trigger_t('songxin_ask2',"^>*\\s*这里没有这个人。$",'','songxin_nobody')
- SetTriggerOption("songxin_ask1","group","songxin_ask")
- SetTriggerOption("songxin_ask2","group","songxin_ask")
- EnableTriggerGroup("songxin_ask",false)
复制代码
这里面DeleteTriggerGroup就是删掉括号里那个分组的触发器,
create_trigger_t是创建触发器的一个子程序,不需要理解太多,照着已有的格式就可以
songxin_ask1,songxin_ask2 这个是触发器的名称,根据自己的需要写上就行1、2、3...一直排下去
然后是触发内容。上面说过怎么写了
最后的songxin_ask songxin_nobody就是调用这两个子程序,比如songxin_ask,在编辑器里面搜索一下,就能找到
- function songxin_ask()
- EnableTriggerGroup("songxin_ask",false)
- EnableTriggerGroup("songxin_accept",true)
- end
复制代码
SetTriggerOption("songxin_ask1","group","songxin_ask") 这个呢,就是把已经命名的触发器分组到songxin_ask里面
这里有个小技巧,和fqyy学的。如果一大堆的触发器放在一个组里
可以写成:
- for i=1,2 do SetTriggerOption("songxin_ask"..i,"group","songxin_ask") end
复制代码
这个就是i从1循环到2,然后把"songxin_ask"..i 名称的触发器,都归到一个组里面,行数多的时候,这样写简单点儿。
比如有20句,只需要改成 for i=1,20就可以了。
我们在zmud的时候也会分组,便于开、关、删除
EnableTriggerGroup("songxin_ask",false) 这个就是关掉这个组,EnableTriggerGroup("songxin_ask",true)就是打开
也可以单独开关分组中的其中一个触发器
EnableTrigger("songxin_killer1",true) 或者 EnableTrigger("songxin_killer1",false)
就和Zmud中的 #t+ #t-用法一样 |
|