How to capture 1 line of several almost identical and manipulate

Posted by Smokebomb on Thu 29 Mar 2012 01:17 PM — 3 posts, 17,914 views.

#0
Hi there! I'm new to Lua and coding in general but have got a small grip on the basics such as variables, strings, functions and operators.
My question is how do I capture parts of 1 line of several similar lines and then manipulate that data with an alias.

Firstly, the line I wish to capture parts of is something like:

You still have to kill * a whittling boy (Child's Play)

Secondly, I wish to capture the mob (a whittling boy) and area of the mob (Child's Play).
Can I use wildcard's or do I need something else? I tried using wildcard's with no luck as a trigger to match the first line of several:

You still have to kill * a whittling boy (Child's Play)
You still have to kill * some sawgrass (The Fire Swamp)
You still have to kill * A Dragon Citizen (The First Ascent)
You still have to kill * A Gargoyle (The First Ascent)
You still have to kill * a bobwhite quail (The Forest of Li'Dnesh)
You still have to kill * a dark brown waterthrush (The Forest of Li'Dnesh)
You still have to kill * the scorpion (The Gauntlet)
You still have to kill * a hidden thief (The Path of the Believer)
You still have to kill * a beer-drinking ratling (Tournament Camps)

I tried the following as the trigger:

You still have to kill * ^\* (*)

And the following as the send:

hold portal
enter
d
rt %2
where %1

Nothing whatsoever happens when i 'campaign check' and the list of mobs left to kill is displayed, not even an error.

I tried asking on the MUD and they said something about regex but that's over my head, I tried looking on Google 'regex Lua' only to get completely confused.
Many thanks in advance,
Smoke-bomb.







#1
http://mushclient.com/forum/bbshowpost.php?id=8815

theres a link to a campaign tracker for aardwolf.
didn't see a game listed so might be same or changeable for your purposes.
Australia Forum Administrator #2
Quote:

You still have to kill * ^\* (*)


It's hard to know what you are doing without seeing the actual trigger.

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


There is a reasonably readable write-up on regular expressions here (written by me *cough* *cough*) ...

Template:regexp
Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.


What you want is easy enough. You will learn more by attempting it yourself. Try to keep it simple.