Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Parse info from a trigger

Parse info from a trigger

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Bortaz   (3 posts)  Bio
Date Mon 05 Nov 2007 06:48 PM (UTC)
Message
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 :)
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #1 on Mon 05 Nov 2007 09:44 PM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,163 posts)  Bio   Forum Administrator
Date Reply #2 on Mon 05 Nov 2007 10:25 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Bortaz   (3 posts)  Bio
Date Reply #3 on Tue 06 Nov 2007 05:55 PM (UTC)
Message
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?
Top

Posted by Nick Gammon   Australia  (23,163 posts)  Bio   Forum Administrator
Date Reply #4 on Tue 06 Nov 2007 08:47 PM (UTC)
Message
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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Bortaz   (3 posts)  Bio
Date Reply #5 on Wed 07 Nov 2007 01:18 AM (UTC)
Message
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.
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #6 on Thu 08 Nov 2007 07:07 AM (UTC)
Message
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
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


26,697 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.