北大侠客行MUD论坛

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

脚本里建的多行trigger触发不了

[复制链接]
发表于 2015-9-12 13:47:21 | 显示全部楼层 |阅读模式
world.AddTriggerEx('hp', '^\>?\s?\#(\S+)\,(\d+)\,(\d+)\,(\d+)\,(\d+)\,(\d+)$\\n#(\d+)\,(\d+)\,(\d+)\,(\d+)\,(\d+)\,(\d+)$', 'dd', 1+32+1024, -1, 0, "", "", 10, 100)
world.SetTriggerOption('hp', "multi_line", 'Y')
world.SetTriggerOption('hp', "lines_to_match ", 2)
world.execute('hpbrief')

这段正则在脚本建了触发不了, 但是在mush里直接建就可以, 有人知道为什么吗?

北大侠客行MUD,中国最好的MUD
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
发表于 2015-9-12 14:07:04 | 显示全部楼层
回复 1# nozshand


    貌似是个老bug,可以尝试参考一下我这个贴子的脚本里的多行触发建立方式看行不行。。脚本有“创建多行触发”注释的那段

http://pkuxkx.net/forum/redirect ... d=295404&ptid=23165
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
 楼主| 发表于 2015-9-12 14:29:40 | 显示全部楼层
回复  nozshand


    貌似是个老bug,可以尝试参考一下我这个贴子的脚本里的多行触发建立方式看行不行 ...
cappuccino 发表于 2015-9-12 02:07 PM


没找到, 但是有个一回复貌似是和我一样的问题, 就是脚本建完后要去mush触发界面那里去点一下确定(什么都不用改)然后就能触发了
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
发表于 2015-9-12 14:37:29 | 显示全部楼层
回复 3# nozshand


    那个istillsun就是我。。。都说了让你去看代码了。。。

无语,直接给你贴出代码来好了。。。
  1.         ------创建多行触发------
  2.         html_replacements = {
  3.            ["<"] = "<",
  4.            [">"] = ">",
  5.            ["&"] = "&",
  6.            ['"'] = """,
  7.            }
  8.         -- fix text so that < > & and double-quote are escaped
  9.         function fixhtml (s)
  10.           return (string.gsub (tostring (s), '[<>&"]',
  11.                 function (str)
  12.                   return html_replacements [str] or str
  13.                 end ))
  14.         end -- fixhtml

  15.         function GeneralAdd (t, which, plural)
  16.           assert (type (t) == "table", "Table must be supplied to add a " .. which)
  17.           local k, v
  18.           local xml = {}
  19.           local send = fixhtml (t.send or "")  -- send is done differently
  20.           t.send = nil
  21.           -- turn into XML options  
  22.           for k, v in pairs (t) do
  23.                 -- fix true/false to y/n
  24.                 if v == true then
  25.                   v = "y"
  26.                 elseif v == false then
  27.                   v = "n"
  28.                 end -- if true or false
  29.                 table.insert (xml, k .. '="' .. fixhtml (v) .. '"')
  30.           end -- for loop
  31.           assert (ImportXML (string.format (
  32.                           "<%s><%s %s >%s",
  33.                                  plural,   -- eg. triggers
  34.                                  which,    -- eg. trigger
  35.                                  table.concat (xml, "\n"),  -- eg. match="nick"
  36.                                  send,     -- eg. "go north"
  37.                                  which,    -- eg. trigger
  38.                                  plural)   -- eg. triggers
  39.                          ) == 1, "Import of " .. which .. " failed")
  40.         end -- GeneralAdd
  41.         function LuaAddTrigger (t)
  42.           GeneralAdd (t, "trigger", "triggers")
  43.         end -- LuaAddTrigger
  44.         LuaAddTrigger {  match = "^.*\\|.*\\|.*\\|.*\\|.*$\\n^.*\\|.*\\|.*\\|.*\\|.*$\\n^.*\\|.*\\|.*\\|.*\\|.*$\\n^.*\\|.*\\|\\s*(\\d+)\\s*\\d+\\s*\\|.*\\|.*$\\n^.*\\|.*\\|.*\\|.*\\|.*\\Z",
  45.                                         regexp = true,
  46.                                         ['repeat'] = true,   -- repeat is lua keyword
  47.                                         send = "qlingwu.maxlevel\("%1"\)",
  48.                                         sequence = 50,
  49.                                         enabled = true,
  50.                                         lines_to_match=5,
  51.                                         multi_line=true,
  52.                                         send_to=12,
  53.                                         group="q_qlingwu",
  54.                                         name="max_level",
  55.                                   }
  56.         ------多行触发结束------
复制代码
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
 楼主| 发表于 2015-9-12 15:03:20 | 显示全部楼层
回复 4# cappuccino

用ImportXML可以触发了, 看来是AddTrigger有bug, 多谢
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
发表于 2015-9-22 10:07:36 | 显示全部楼层
学习中~~~~~
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-27 06:10 AM , Processed in 0.012392 second(s), 14 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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