AutoQuester

Post Reply
daemoen
Posts: 7
Joined: Wed Jul 14, 2010 8:09 pm

AutoQuester

Post by daemoen »

Ok, started mudding again, and so now I am having fun writing different scripts... unfortunately, I have run into one that I am not quite sure how to solve within mudlet

The mud I play is a classic godwars style mud with "quest cards" that you can complete.

Sample output: (used lua because its preformatted)
Code: [show] | [select all] lua
You still need to find the following:
     an apple pie.
     a suit of field plate.
     an imperial chest plate.
     an electrum belt.
Now, I would like to be able to store each of the results in a 2 column db.... (item name, action list)

I'm pretty sure I can figure out how to do the db side of it, the part that I am not certain of is how to loop through the list. Each time you "complete" part of the card, the list shortens, so if I had completed the apple pie requirement, the output would change to:
Code: [show] | [select all] lua
You still need to find the following:
     a suit of field plate.
     an imperial chest plate.
     an electrum belt.
Not looking for anyone to write any code for me, just looking for guidance on how to handle the looping in mudlet triggering so that I can start to work through it :)

Thanks

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: AutoQuester

Post by chris »

Use the consistencies in the data. Does it always end with a line? If so, have the You still... activate a trigger that populates the list with all the following lines, then have the line you end with deactiavte the trigger (or deactiavte on the next line w/o the spacing)

Golem
Posts: 30
Joined: Thu Feb 07, 2013 6:46 pm

Re: AutoQuester

Post by Golem »

It does seem most reasonable to look for lines with the given spacing (are those spaces or tabs?) plus starting with (a|an)\s?

As for the db side, I do prefer to stick to lua tables, for the simplicity sake, but that is just a preference.

Good luck, G.

Lucky24
Posts: 52
Joined: Sun Sep 12, 2010 1:50 am

Re: AutoQuester

Post by Lucky24 »

I had a similar parsing problem. The trick is to match the first line ("You still need to find the following:"), change the fire-length to something reasonable (the maximum number of things you might still need to find), then make two sub-triggers. Thus, the sub-triggers will fire for each subsequent line until your sanity check fire-length is exceeded.

The first sub-trigger should matches any lines that *dont* make sense in your list. You use this match to call the function setTriggerStayOpen("your_parent_trigger_name", 0). This function will immediately stop the trigger specified from parsing any additional lines.

On the second sub-trigger you make a match that makes sense for what you want to capture. In your case perhaps a regex like
Code: [show] | [select all] lua
\s+(a|an) (.+)\.$
, which should only match lines that start with spaces, have 'a' or 'an' in them, and end with a period.

You can of course do more logic to detect if the line captured makes sense. If it doesn't fit what should be in the list, call setTriggerStayOpen("parenttrigger",0) to stop any more lines from capturing. If it does make sense, you add it to your table of things you need to find.

P.S. Something else that always happend in my case was that there was a blank line after the list. So, I could be sure the list was done when I saw a blank line.

Post Reply