Not reading the 3rd Wildcard...

Posted by Neoshain on Fri 12 Jul 2013 04:28 AM — 6 posts, 22,874 views.

#0
Here is what I wish to match
Quote:

Mon Calamari MC80 Cruiser: Independence 1357 -2245 4112


And I'm trying to take all three coordinates and then add 300 to the final one. My following trigger:


<triggers>
  <trigger
   custom_colour="6"
   enabled="y"
   group="CapTracking"
   ignore_case="y"
   make_bold="y"
   make_italic="y"
   make_underline="y"
   match="Mon Calamari MC80 Cruiser\: Independence    (.*?) (.*?) (.*?)"
   name="IndependanceTracking"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>IndependenceLocation = ("%3"+300)
Note("%1")
Note("%2")
Note("%3")
Note(IndependenceHyper3)</send>
  </trigger>
</triggers>


Is matching only the following:
Quote:

Mon Calamari MC80 Cruiser: Independence 1357 -2245 4112


I don't know what the problem is.

Lua Scripting. MUSHClient v4.84
#1
Both of the Variables listed in send should read IndependenceHyper3, not IndependenceLocation
#2
One other thing, I would like to compensate for a possible variation on in the amount of spaces between a ship's name and the coordinates listed, how would I do this?
Australia Forum Administrator #3
It's always a bit fraught matching on .* because the "." wildcard matches spaces too, so hoping it will all work is pushing it. Specifically matching for numbers (and the minus sign) is better:


<triggers>
  <trigger
   custom_colour="6"
   enabled="y"
   group="CapTracking"
   ignore_case="y"
   make_bold="y"
   make_italic="y"
   make_underline="y"
   match="Mon Calamari MC80 Cruiser\: Independence\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)"
   name="IndependanceTracking"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
IndependenceHyper3 = %3 + 300
Note("%1")
Note("%2")
Note("%3")
Note(IndependenceHyper3)</send>
  </trigger>
</triggers>


The above also allows for any number of spaces ( \s+ ).
#4
Gotcha! Thank you! I had messed around with it a bit more last night and got this to work:


Mon Calamari MC80 Cruiser\: Independence    (.*?) (.*?) (.*)


But yours, (being... ya know... YOURS) is better, of course. Thank you!

I'm slowly but surely become the Lua "expert" of my Mud's pbase and it's all thanks to you and the active forum members here! I've had a lot of people ask me to build custom triggers and plugins and stuff for them now, and whenever I get stumped, you guys are fast and so helpful! Thank you so very much. I hope to be one of the people who can help and answer questions as well as you some day! I've only been doing Lua since about March or April, and it's very casual, so I need this type of help! You Rock!
Amended on Fri 12 Jul 2013 03:04 PM by Neoshain
#5
I would like to mention something about spaces here as Nick previously wrote it in his help documentation.

1. For a single space the patern should be \s

2. For a single-multiple spaces Patern could be \s+?

3. For a non-space or multiple spaces Patern could be \s*?

If we want to assign these spaces to a wildcard () is used.


like (\s*) will assign spaces to relative wildcard.

If we want to give a name to wildcard we can use,
(?P<test>\s*)
which will be probably nil. (for spaces)

to be able to use it in triggers/aliases etc since it has more then 1 character you must use %<test>.
Do not forget to put use "" if %<test> is a string.