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
markov
Beginner


Joined: 09 Aug 2004
Posts: 11

PostPosted: Wed Aug 25, 2004 6:27 pm   

Prefixing incoming strings while maintaining color
 
I'm trying to find a way to prefix damage ranges to incoming text from the MUD without removing the color and for the damage strings to be applied to any string from the MUD that _contains_ the strings.

The input from the MUD:
Code:

Dorain lands [ 2 of 3 ] attacks on a five point deer: wounding damage.
Dorain's striking fist scathes a ferocious boar!
You land [ 3 of 3 ] attacks on a five point deer: scathing damage!
You focus on decaying a ferocious boar's mind, he screams in pain as you scathe him!
You kick misses a boar but still scratches him!



The output that I'm trying to achieve (while trying to maintain color)
Code:

[200-400] Dorain lands [ 2 of 3 ] attacks on a five point deer: wounding damage.
[100-200] Dorain's striking fist wounds a ferocious boar!
[900-1200] You land [ 3 of 3 ] attacks on a five point deer: scathing damage!
[300-400] You focus on decaying a ferocious boar's mind, he screams in pain as you scathe him!
[1-100] You kick misses a boar but still scratches him!
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Wed Aug 25, 2004 6:46 pm   
 
For each of these lines, get a trigger that matches them. You may need to escape the [ and ] with ~ or whatever your escape character is. I didn't when I test it with "You land [ 3 of 3 ] attacks on a five point deer: scathing damage!"

Then for the command use: #SUB {~[1-100~] %line}
This should maintain the colour. Above example is obviously just for the scratch comand, but the same principle applies to all of them. I found using %line worked much better than %1 or anything else if there were strange characters in the line.

Seb
Reply with quote
markov
Beginner


Joined: 09 Aug 2004
Posts: 11

PostPosted: Wed Aug 25, 2004 7:54 pm   
 
It didn't maintain the color code :(


Last edited by markov on Wed Aug 25, 2004 8:02 pm; edited 1 time in total
Reply with quote
markov
Beginner


Joined: 09 Aug 2004
Posts: 11

PostPosted: Wed Aug 25, 2004 7:58 pm   
 
PS: There's 6 colorcodes in the string. It *does* preserve the beginning of the line but then applies ot to the whole line
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Aug 26, 2004 1:33 am   
 
Use #PSUB instead of #SUB. You can bypass the usage of %x1 that is shown in the examples by simply using numbers. For example:
#TR {whichever line} {#PSUB {This was } 1 1}
Should turn all instances of "whichever line" into "This was whichever line".
I am not sure whether #PSUB takes a 0 or a 1 for first column though, so the correct might be:
#TR {whichever line} {#PSUB {This was } 0 0}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
markov
Beginner


Joined: 09 Aug 2004
Posts: 11

PostPosted: Thu Aug 26, 2004 8:11 am   
 
Turned out to be like this :P I tried -1, but yeah it dodn't work a I thought
I did:
Code:

#ac {whichever line} {#PSUB {This was } 0 0}
This washichever line

#ac {whichever line} {#PSUB {This was } 1 1}
wThis wasichever line


Any way to make it go back -1 somehow?
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Thu Aug 26, 2004 2:14 pm   
 
Quote:

Any way to make it go back -1 somehow?

Not that I know of. But it seems like a bug that 0 to 0 in #PSUB is actually interpreted as 0 to 1. In other words XEnd is one higher than it should be, but if you give it -1, it doesn't work.

It also seems like a bug in #SUB if only the first colour in the line is retained. %line captures all the colours in the line.

Sorry - you don't seem to have much luck. Obviously, you could use %ansi to put the colours back in where you want them manually though.

Seb
Reply with quote
markov
Beginner


Joined: 09 Aug 2004
Posts: 11

PostPosted: Thu Aug 26, 2004 4:11 pm   
 
Thanks though, I guess I'll try to figure it out later :(
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