Having some strange problems

Posted by Hisoka on Sat 11 Jun 2011 02:55 PM — 2 posts, 13,680 views.

#0
Greetings,

I'm having some strange problems.

First:
I'm not able to use \w+ for any letters.

Alias: target (\w+)
Send: Note(%1)

If I type: target 333, it says 333.
If I type: target abc, it says nil.
If I type: target a1, it says nil.

Second:
Trigger: ((\w+) feels fine)
Send: Send(%1)

Error:
Compile error
World: Avalon
Immediate execution
[string "Trigger: "]:1: ')' expected near 'feels'


RegEx is enabled, I'm using LUA as script language.

Thanks for any advices,
Hisoka
Netherlands #1
Look at your input and the way it is evaluated.

Trigger: target (\w+)
Send: Note(%1)

From this, we can reason towards:

Captured groups: just one, which is matched by the regexp \w+
Substituted 'Send' for 'target 333': Note(333)
Substituted 'Send' for 'target abc': Note(abc)
Substituted 'Send' for 'target a1': Note(a1)

Does that clear it up any? The clue is that you are using Send to Script.

Your problem is that you do not properly understand how MUSHclient and Lua work together. Basically, when MUSHclient substitutes wildcards and variables, the resulting text has to be a valid script.

And while the commands are a valid script, they are not what you intended for anything but the number case. Note(abc) will output the contents of the Lua variable abc. Instead, you want the literal string abc, so you want the substituted Send to look like Send("abc"). In comparison Note(123) interprets 123 as a number, which Lua knows how to turn into a string for this purpose.

Thus, you need:
Send: Note("%1")

The exact same cause lies at the roots of your other example with Send().