Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
coral
Newbie


Joined: 30 Aug 2007
Posts: 2

PostPosted: Thu Aug 30, 2007 3:43 am   

Account MUD, prompt matching question
 
Hello everyone.

I'm working on making a script for my MUD, but I'm having problems matching the mud prompt. The thing is my MUD uses an account system, with characters within that account. So, generally, there's only 1 configuration setting for the account and I need something to match our customizable prompt. The prompt can have as many fields as:

02:46:03 H:38 M:100 P:100.0 LF:65 V:126 T:0 E:57,240,329 N:12,739,133 >

People will usually either have the M:, P: or LF: depending on which class they're playing, and the E: or N: can be a number from 1 to 29,834,768,858.

I thought about buttons that would turn on the right trigger and adjust the prompt for that trigger, but I'm not sure how to match the numbers in the E: or N: field, because of the commas there.

Ideas?![/list]
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Thu Aug 30, 2007 4:21 am   
 
Use %n to capture numbers with comas in them. %x also would work or [0-9,]
of those [0-9,] is the better option and we can use it to build a regex pattern.

Here is a REALLY cool regex pattern for your prompt

Code:
\d+:\d+:\d+\sH:(\d+)\s(?:M:([0-9,]+)\s)*(?:P:([0-9,\.]+)\s)*(?:LF:([0-9,]+)\s)*(?:V:([0-9,]+)\s)*(?:T:([0-9,]+)\s)*(?:E:([0-9,]+)\s)*(?:N:([0-9,]+)\s)*>


just set up a load of variables going down the line.

health=%1
mana=%2
p=%3
LF=%4
V=%5

and so on. If a piece of the prompt is left out then it will just set that part to NULL. An example.

02:46:03 H:38 P:100.0 LF:65 V:126 T:0 E:57,240,329 N:12,739,133 >

In the above prompt the M:100 is missing so %2 returns NULL, but P would be set to 100.0 properly as would the following variables.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
coral
Newbie


Joined: 30 Aug 2007
Posts: 2

PostPosted: Thu Aug 30, 2007 11:50 pm   
 
OH MY GOD you're my HERO :)

The part for the time stamp didn't work, but once I removed it it matched my prompt beautifully :)

This is indeed a nice trigger, and you helped me understand a lot of regex patterns with this example. I can't thank you enough.

*HUG*
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net