脚本里建的多行trigger触发不了
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 回复 1# nozshand
貌似是个老bug,可以尝试参考一下我这个贴子的脚本里的多行触发建立方式看行不行。。脚本有“创建多行触发”注释的那段
http://pkuxkx.net/forum/redirect.php?goto=findpost&pid=295404&ptid=23165 回复nozshand
貌似是个老bug,可以尝试参考一下我这个贴子的脚本里的多行触发建立方式看行不行 ...
cappuccino 发表于 2015-9-12 02:07 PM http://pkuxkx.net/forum/images/common/back.gif
没找到, 但是有个一回复貌似是和我一样的问题, 就是脚本建完后要去mush触发界面那里去点一下确定(什么都不用改)然后就能触发了 回复 3# nozshand
那个istillsun就是我。。。都说了让你去看代码了。。。
无语,直接给你贴出代码来好了。。。 ------创建多行触发------
html_replacements = {
["<"] = "<",
[">"] = ">",
["&"] = "&",
['"'] = """,
}
-- fix text so that < > & and double-quote are escaped
function fixhtml (s)
return (string.gsub (tostring (s), '[<>&"]',
function (str)
return html_replacements or str
end ))
end -- fixhtml
function GeneralAdd (t, which, plural)
assert (type (t) == "table", "Table must be supplied to add a " .. which)
local k, v
local xml = {}
local send = fixhtml (t.send or "")-- send is done differently
t.send = nil
-- turn into XML options
for k, v in pairs (t) do
-- fix true/false to y/n
if v == true then
v = "y"
elseif v == false then
v = "n"
end -- if true or false
table.insert (xml, k .. '="' .. fixhtml (v) .. '"')
end -- for loop
assert (ImportXML (string.format (
"<%s><%s %s ><send>%s</send></%s></%s>",
plural, -- eg. triggers
which, -- eg. trigger
table.concat (xml, "\n"),-- eg. match="nick"
send, -- eg. "go north"
which, -- eg. trigger
plural) -- eg. triggers
) == 1, "Import of " .. which .. " failed")
end -- GeneralAdd
function LuaAddTrigger (t)
GeneralAdd (t, "trigger", "triggers")
end -- LuaAddTrigger
LuaAddTrigger {match = "^.*\\|.*\\|.*\\|.*\\|.*$\\n^.*\\|.*\\|.*\\|.*\\|.*$\\n^.*\\|.*\\|.*\\|.*\\|.*$\\n^.*\\|.*\\|\\s*(\\d+)\\s*\\d+\\s*\\|.*\\|.*$\\n^.*\\|.*\\|.*\\|.*\\|.*\\Z",
regexp = true,
['repeat'] = true, -- repeat is lua keyword
send = "qlingwu.maxlevel\(\"%1\"\)",
sequence = 50,
enabled = true,
lines_to_match=5,
multi_line=true,
send_to=12,
group="q_qlingwu",
name="max_level",
}
------多行触发结束------ 回复 4# cappuccino
用ImportXML可以触发了, 看来是AddTrigger有bug, 多谢 学习中~~~~~
页:
[1]