Parse info from a trigger

Posted by Bortaz on Mon 05 Nov 2007 06:48 PM — 7 posts, 31,278 views.

#0
Hello, I have been using Mushclient for a while now and am just starting to get into some of the other functions that are available from the client.

I was wondering if it is possible to capture text with a trigger in MUSHclient, and then parse this info into a Lua table.

Info would look something like this

A Cityguard Stands here.
A kobold attacks you!
The grocer is here.

If this is possible any help would be appreciated :)
USA #1
It would be difficult, unless the messages followed a standard and fairly constant syntax.

I have been working on a target cycler for DB Evolution, that allows me to 'look' in a room, and use 1 button to cycle forward and another back, and set the "target" variable accordingly, as well as prepend the #. to the name if more than one is in the room. The issue with this is that things can "stand", "walk", "jog", "waddles", etc. Usually it ends with "here.", but there are also items that would be captured, so it takes some careful scanning of these things and prevent adding them to the table, and if it fails all the prevention checks then it is added.

I can say with 100% certainty, if it does not follow a regular message pattern, and can be ANYTHING, then this will a very difficult, if not impossible thing to script.

I will post a copy of my triggers and aliases when I am at home, and can do so. (Am at computer lab right now, and forgot to drag mushclient back to USB drive)

-Onoitsu2
Australia Forum Administrator #2
Quote:

I was wondering if it is possible to capture text with a trigger in MUSHclient, and then parse this info into a Lua table.


That is certainly possible, although as Onoitsu2 points out, a lot depends on what you want to do with the information.
#3
well say the things i am trying to parse do follow a regular syntax that does not change. is there a general way that i can script this information to go into a table?
Australia Forum Administrator #4
It is hard to be more specific without knowing what you are wanting to do, but look up string.gmatch. With that you could break a line of text into words, then each word could be put into a table.

http://www.gammon.com.au/scripts/doc.php?lua=string.gmatch
#5
Ok thanks that sounds like what I might need, I will mess with this and try to come up with something and if I have any questions I will report back here.
USA #6
I have extracted the few triggers and 2 needed aliases for this task, and put them into a plugin. This is still using a Mushclient variable to do the work, because this was implemented directly within my world file, and I do not use a script file.

www.torasin.com/~venificius/DBE_Target_Cycle.xml

Sadly the URL is VERY case sensitive, tried talking to my friend that is hosting it and has not gotten around to playing with it. Some times it will not even matter, other times it will.

This was created for use on Dragon Ball Evolution, but can easily be altered to work for other things.

Basically it triggers on the output of "Look" or "Scan" or the automatic "Look" that occurs when you enter a room. It sets the clipboard to the selected target, and then allows you to use the clipboard via %C in 'send to world', or GetClipboard() in 'send to script'. You might want to make a clear_clipboard alias, and possibly bind it to a key as well as, like the "Help File" describes, 'fmob' and 'pmob' commands as well.

Hope this is decipherable.

-Onoitsu2