[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  A complicated regex Trigger

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: A complicated regex Trigger
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  3  

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Thu 11 May 2006 10:22 PM (UTC)  quote  ]
Message
Well it won't if you anchor the regexp to the start or the end of the 3 lines. If you don't, well it is working as intended.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nexes   (65 posts)  [Biography] bio
Date Thu 11 May 2006 09:52 PM (UTC)  quote  ]
Message
Meh, it's not really important any more since the screenwidth 0 option is in, but before, if you had a regex pattern set to multiple lines, say 3, and it was caught on one line, it would fire 3 times anyways for that single line. The reason I posted here was to figure out if there was a way around this and there isn't so I decided to simply start parsing the text in a big block.
[Go to top] top

Posted by Rakon   USA  (123 posts)  [Biography] bio
Date Mon 08 May 2006 06:05 PM (UTC)  quote  ]
Message
Quote:
The trigger pattern you mentioned is exactly what I wanted to avoid, since it fires multiple times if it comes in less lines than I set the trigger to capture. Also I don't want to limit the capture to only my target.


The reason for setting a target is so that it only matches the line the targets name is in. Thus, it should not fire multiple times unless you QL more then once. Really, without defining a target for the system to look for, won't you in essence, overwrite the variables everytime it makes a match???

Or am I utterly confused as to what you are trying to do??

Yes, I am a criminal.
My crime is that of curiosity.
My crime is that of judging people by what they say and think, not what they look like.
My crime is that of outsmarting you, something that you will never forgive me for.
[Go to top] top

Posted by Nickpick   (24 posts)  [Biography] bio
Date Mon 08 May 2006 05:18 PM (UTC)  quote  ]
Message
Not sure if it was said yet, but if you are talking about Achaea, try CONFIG SCREENWIDTH 0.
[Go to top] top

Posted by Nexes   (65 posts)  [Biography] bio
Date Fri 05 May 2006 03:06 AM (UTC)  quote  ]
Message
I read about the screenwidth 0 thing the moment the put it in and I love it.

Actually that brings Nick's point even more relevant since I definitely will run into that limit on packet size now, at least if I send it all in one packet.

Anyways, the reason I don't want to do it your way, Rakon, is because that's not quite what I wanted to do. The trigger pattern you mentioned is exactly what I wanted to avoid, since it fires multiple times if it comes in less lines than I set the trigger to capture. Also I don't want to limit the capture to only my target.
[Go to top] top

Posted by Rakon   USA  (123 posts)  [Biography] bio
Date Mon 01 May 2006 07:32 PM (UTC)  quote  ]
Message
Well now. Achaea now allows you to CONFIG SCREENWIDTH 0, so try that if you'd like. However I'd think it'd be much simpler to target a person IE 'set summoner Yuna/<person>', and have a trigger match on the line that the name is in. In Cyan or whatever you use for a 'player' color. Thus, when the trigger matched you could make the REGEX '(She|he) is wielding (a|an) (.*?) in (his|her) (right|left) hand
.' I don't know how you'd account for a newline in the description however, maybe use the REGEX to do a few ( |\n) ??
Good Luck

--Rakon

Yes, I am a criminal.
My crime is that of curiosity.
My crime is that of judging people by what they say and think, not what they look like.
My crime is that of outsmarting you, something that you will never forgive me for.
[Go to top] top

Posted by Nexes   (65 posts)  [Biography] bio
Date Thu 16 Mar 2006 12:25 AM (UTC)  quote  ]
Message
My screen width is already set at 240.

Hmm, I guess I would have to figure out the max length of a UDP packet, and figure out how many charachters that translates into. If it's above 240 then it shouldn't be a problem, otherwise maybe your method would be better Nick.
[Go to top] top

Posted by Tsunami   USA  (204 posts)  [Biography] bio
Date Wed 15 Mar 2006 04:30 PM (UTC)  quote  ]
Message
Might I suggest a way to make this easier? (wouldn't want to take away from your project though Nexes, hehe)

CONFIG SCREENWIDTH 250

and set MushClient to do your wrapping for you... It won't be perfect, since descriptions are often longer than 250 characters, but it might make things a bit easier.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 15 Mar 2006 05:48 AM (UTC)  quote  ]
Message
Quote:

Yeah, Im going to use UDP to send it to a C++ program and have it parse it into sentences


Personally I wouldn't use UDP in this application. A UDP packet is limited in size (something around 512 bytes) so a long description would need to be split between packets, reassembled at the receiving end, and so on.

If you look at this forum post:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6034

... I did 200,000 string.find operations (that is, the Lua regexp) in one second, so I don't think speed will be an issue. Also, I recently wrote an application in Lua that read in all my old email messages, parsed the headers, and added them to an SQL database. The whole thing ran really fast, processing something like 5,000 emails in a minute or so. There was no problem with string management.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nexes   (65 posts)  [Biography] bio
Date Wed 15 Mar 2006 12:11 AM (UTC)  quote  ]
Message
I meant Java. I dunno, maybe my virtual machine sucked :(
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Tue 14 Mar 2006 09:51 PM (UTC)  quote  ]
Message
Do you mean Java or Javascript? I've not had problems you describe using strings in Java. There are some gotchas, especially if you're building very large strings a few characters at a time, in which case you actually want to use a StringBuffer (or StringBuilder in 1.5 I think it's called). That way, you allocate a chunk of memory once, and then fill it up. But, this also applies to C++ strings.

But again, I'd be quite surprised if you had problems with strings in Java. I wrote a program for work that takes several hundred session logs, reads them all in, does black magic on them involving very many string operations per session, and the blocking part is disk access, not string manipulation.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nexes   (65 posts)  [Biography] bio
Date Tue 14 Mar 2006 09:42 PM (UTC)  quote  ]

Amended on Tue 14 Mar 2006 09:44 PM (UTC) by Nexes

Message
I use UDP because of the MUSHClient supplied functions for sending and receiving UDP packets. Otherwise, I have no idea how I would establish a connection between MUSHClient and my program. :(

And I distrust string operations because of my experience in Java. It was...incredibly slow with the strings. Concatenating, and everything else really ate up my memory and while I found the string buffers in Lua to be exceedingly simple to use I have since distrusted string operations.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Tue 14 Mar 2006 05:29 AM (UTC)  quote  ]
Message
Oh, I didn't know you were doing all that other stuff. In that case it makes sense to have C++, especially if you've already written all this other code for it.

I was surprised to hear you say UDP, and not just plain old normal TCP sockets, examples of which abound for Winsock. UDP seems to be a slightly more unusual route to me.

FWIW, Lua is an extremely fast scripting language. It is more than sufficient for any kind of processing people would be doing for a MUD. People can render 640x480 images at hundreds of frames per second with Lua doing the grunt-work; surely that is sufficiently fast for a measly little text parser? :-)

(Don't forget that text parsing is really a very inexpensive task in general. If you don't believe me, write some perl scripts that chunk over megabytes of data and do something (un)interesting. You might be surprised by the speed results.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nexes   (65 posts)  [Biography] bio
Date Tue 14 Mar 2006 05:23 AM (UTC)  quote  ]
Message
C++ classes, OOP design for my combat system. Also, GUI components that I can't create inside of MUSHClient. And it's faster for processing complex tasks. I chose UDP because I know nothing about COM objects and UDP was the only other method that people have mentioned to send data to a third (second?) program. I also could have written DLLs for Lua in C but frankly I felt this was also unnecessary considering I could just use a full blown executable with gauges, buttons, and the works.

Also, less logical, but I know C++ is fast and I feel more comfortable writing complex and computationally expensive functions in it than I would in any scripting language.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Mon 13 Mar 2006 09:55 PM (UTC)  quote  ]
Message
I wouldn't worry about the speed consequences of this. All you're doing is moving some bytes to a running program, which will split into sentences. All of this is quite cheap, computationally.

I'm curious though why you're sending this to an external program, and why you chose UDP. Why not just have a running Lua script that takes care of this for you?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] 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.


9,087 views.

This is page 1, subject is 3 pages long: 1 2  3  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]