Problem with grabbing information from a wildcard.

Posted by Batista on Sat 25 Mar 2006 09:15 AM — 5 posts, 19,308 views.

#0
I'm having some difficulty pulling information from my prompt.

This is what the prompt looks like:

3380h, 3718m, 15800e, 15800w cexdb-


Right now, my prompt trigger is this:

(?P<chp>\d+)h, (?P<cmp>\d+)m, (?P<cend>\d+)e, (?P<cwill>\d+)w ([cexkdb@]*)-


MUSH recognizes the prompt and acts accordingly. Well... almost.

For sipping and whatnot, it works just fine. The values for the wildcards register normally EXCEPT for that last part: ([cexkdb@]*). I don't know why. No matter what configuration I use, be it that or (.*?) or even just a regular * with no regexp stuff in the trigger, it always ALWAYS registers as 'nil'.

Any idea what's going on?
Australia Forum Administrator #1
You realise your last wildcard doesn't have a name? The others do. What are you testing, which equals nil?

I tried your trigger with your example and it worked. I used the ExampleTrigger script which ships inside the exampscript.lua file that comes with MUSHclient. This is what I saw:


Trigger  fired.
Matching line was: 3380h, 3718m, 15800e, 15800w cexdb-
Wildcards ...
1="3380"
2="3718"
3="15800"
4="15800"
5="cexdb"
"chp"="3380"
"cwill"="15800"
0="3380h, 3718m, 15800e, 15800w cexdb-"
"cmp"="3718"
"cend"="15800"
Line with style runs ...
1:
  "textcolour"=12632256
  "backcolour"=0
  "length"=35
  "style"=0
  "text"="3380h, 3718m, 15800e, 15800w cexdb-"


You can see that your last wildcard (number 5) was returned OK.
#2
That's what is so frustrating. It -should- work. There's nothing wrong with it. It just... doesn't.

To test it, I use the Note() function. Whenever I have it report all wildcard values, I get all the correct stuff... EXCEPT for the last wildcard.

I'll put Note(%5) under that trigger in the send box and it'll report 'nil'.

*scream*
Australia Forum Administrator #3
Quote:

I'll put Note(%5) under that trigger in the send box and it'll report 'nil'


You have to think about what is happening here. MUSHclient literally substitutes the trigger wildcard for the %5, so what you are getting is:

Note (cexdb)

This is listing the contents of variable cexdb which does not exist, and is thus nil.

You want:

Note ("%5")

The others worked because they are numbers, eg.

Note (3380)

That would work.
#4
... oh. Well, hmm. It works now, heh. Sorry for the stupid question. *grin* Shoulda thought of that myself.

Thanks for the help! :D