Trevize said:
Am I a retard again or not making my point clear :(
trigger_add("^You (\d+) Points\.$", nil, nil, "Replaced")
function trigger_add(pattern, send, script, replace)
table.insert(tTriggers, { pattern = pattern, send = send, script = script, replace = replace })
end
This is how I add my "so called" triggers into the table that checks against the mud's output. The problem I'm having is that the string that's in tTriggers table now does'nt match because it's like this: ^You (d+) Points.$
You showed me that I could use [[ ]] to fix that problem, but it seems to me that the only way to add a long string like that with my function is to supply it in the "call" to the function, like:
trigger_add([[^You (\d+) Points\.$]], nil, nil, "Replaced")
And I was hoping that I would'nt have to do that because (to me) it looks more ugly and possible harder for anyone else using this function to understand. I had hopes that I could do something like I have, and just make the insert do this: table.insert(tTriggers, { pattern = [[pattern]], send = send, script = script, replace = replace }) or something similiar..
Anyway I'm starting to think that it's either that or double "\" to escape the second backslash..
Thanks for your time and patience with me and this thread. It's much appreciated!
Use this.
trigger_add("^You (\\d+) Points\\.$", nil, nil, "Replaced")
Or this.
trigger_add([[^You (\d+) Points\.$]], nil, nil, "Replaced")
It's really the only way. This is something you have to deal with at the syntactic level. Once the string is parsed, there's no going back to fiddle with the escapes. |