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


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Wed May 21, 2003 12:24 am   

MXP color text replacements question...
 
I tried to search for the answers to this but the search feature kept timing out so I'm just going to post. If it's been answered before I apologize, but it really isn't my fault I couldn't find it.

So here goes... I'm trying to figure out how to use MXP commands within trigger scripts to replace mud output text with the same text only with specific RGB colors and background colors using the <color> command.

For example, if I want to change the text of a message recieved on teh "gossip" chat channel to have a light grey text on a dark, grayish-blue background (#C0C0C0 and #3F587D respectively in hex RGB) I would need to do something along the lines of the following (assuming my understanding of the MXP command is right):

#SUB {(*gossips*)} {~<color #C0C0C0 #3F587D>(%1)~</color>}

The problem I'm running into with this type of trigger, and also with using triggers such as:

#TRIGGER {(*gossips*)} {#SUB ~<color #C0C0C0 #3F587D>(%1)~</color>}

Is that I keep getting syntax errors at the point of the "#" characters.

I tried leaving the # characters out entirely, I tried both capitol and lower case letters in the hex RGB numbers, and I tried placing a "~" in front of the # characters and still got sytax error reports in teh settings editor. Am I doing something wrong with this?

Hang on, I just had a thought... What about:

#TRIGGER {(*gossips*)} {#SUB {~<color #C0C0C0 #3F587D>(%1)~</color>}}

Would those extra "{" and "}" characters make the difference?

Let me try that and get back to you :)

Mordann
Reply with quote
Mordann
Beginner


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Wed May 21, 2003 12:34 am   
 
OK, that didn't work right... it reported "{<color" in my standard zMUD info text as specified by my color settings in my preferences.

Now if I do it like this:

#TRIGGER {^*gossips*} {#SUBSTITUTE {~<color #c0c0c0 #3f587d>*gossips*~</color>}}

It get's it right except that it doesn't change the text of teh line to the same text with the specified colors, it changes the text to "*gossips*" with the specified colors, so I have to use the text capture and then use pre-defined variable parameters (i.e. %1, %2, %3, etc.). So I tried:

#TRIGGER {^(*gossips*)} {#SUBSTITUTE {~<color #c0c0c0 #3f587d>(%1)~</color>}}

and:

#TRIGGER {^(*)(gossips)(*)} {#SUBSTITUTE {~<color #c0c0c0 #3f587d>(%1)(%2)(%3)~</color>}}

And they both reported "{<color" in my standard zMUD info text as specified by my color settings in my preferences.

So now what? Anyone have any suggestions?

Mordann
Reply with quote
Lain
Novice


Joined: 26 Oct 2001
Posts: 38

PostPosted: Wed May 21, 2003 12:52 am   
 
I'm not clear on this {(*gossips*)}, if you want to substitute the text before and after the word "gossips",

#TR {(*) gossips (*)} {#SUB {~<color #c0c0c0 #3f587d>%1 gossips %2~</color~>}}

Lain
Reply with quote
Mordann
Beginner


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Wed May 21, 2003 12:59 am   
 
OK, the mud I use has a gossip channel that most people use to communicate to each other with. The line starts with "<charactername> gossips-<message>".

What I want to do (and this is really just so I can figure out how to do other types of text lines as well) is make it so that the MXP color command changes the entire line of text from teh message to a different color.

Now, I can use the #COLOR command like I used to, but that command doesn't allow custom RGB colors, it only does ASCII colors which is fairly limiting. So I want to use the MXP color command instead to do it. What I want to do is replace the entire line with the same exact text only in a different color, so I tried (*gossips*) and (*)(gossips)(*) in order to try and capture and change the WHOLE line... the first * is the character name and a space, the second one is the message preceeded by a hyphen, because that's the syntax from the MUD server.

That help explain what I'm looking to do?

Mordann
Reply with quote
Mordann
Beginner


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Wed May 21, 2003 1:03 am   
 
OK, I tried it the way you suggested, like this:

#TR {(*) gossips (*)} {#SUB {~<color #c0c0c0 #3f587d>%1 gossips %2~</color~>}}

and it worked right, but why did it NOT work with it like this:

#TRIGGER {^(*)(gossips)(*)} {#SUBSTITUTE {~<color #c0c0c0 #3f587d>(%1)(%2)(%3)~</color>}}

or this:

#TRIGGER {^(*gossips*)} {#SUBSTITUTE {~<color #c0c0c0 #3f587d>(%1)~</color>}}

???

Well, thanks for the help :) I think I can get it to work from what you gave but I still don't understand why it didn't work the way I was doing it *shrugs*

Mordann
Reply with quote
Lain
Novice


Joined: 26 Oct 2001
Posts: 38

PostPosted: Wed May 21, 2003 1:29 am   
 
Not sure, they both work fine for me. Although you don't need the brackets around the %1 %2 %3 in your value, this would end up substituting the text "Someone gossips Hello." with "(Someone) (gossips) (Hello.)".

I would think there is a simpler way to colour a line of text other than substituting the text.
Reply with quote
Mordann
Beginner


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Wed May 21, 2003 2:25 am   
 
Well you can use the #COLOR command within a trigger to set a whole line of text by specifying foreground and background colors with a single number (there's info on how to do it and how to figure out what munber corresponds to what fore- and back- ground colors) and it is much simpler than replacing the entire line of text, however, you are limited to 16 colors with that command whereas the MXP <color> command allows for roughly 16.6 MILLION custom RGB colors. That's why I wanted to do it this way is so that I could use custom colors. I didn't see anything in the help file that indicated to me that it's at all possible to make the MXP <color> command work for a whole line without replacing all the text in the line, but if you or someone else happens to know how to do it than I'd love to know :).

Mordann
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed May 21, 2003 4:23 am   
 
1. You say you get a "syntax error", but what you don't say is whether the trigger appears to work. If the trigger seems to work, stop trying to get rid of the "syntax error" and just send in a bug report on it. It's not unusual for the editor's syntax checker to report "errors" on uses Zugg hadn't thought of, but that do work. He would like the opportunity to correct such errors though.

2. You can use MXP colors with the #COLOR command. However, any background color will extend well to the right. This is also true for the 16-color palette.
#TR {gossips} {#COLOR #C0C0C0,#3F587D}

LightBulb
Advanced Member
Reply with quote
Mordann
Beginner


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Wed May 21, 2003 11:59 am   
 
AHHH! I didn't realize you could use MXP colors with the #COLOR command, so that will deffinitely make things easier :) thanks. And I don't know if it worked even with the sytax error reports, I don't think I tried it... I think I assumed if it reported a syntax error then it wouldn't work, so I guess I'll try from now on :). Thanks LightBulb :)

Mordann
Reply with quote
Mordann
Beginner


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Wed May 21, 2003 8:56 pm   
 
OK new issue...

I have the following trigger:

#TRIGGER {^<%dhp %dma %dmv>} {%if( @CHPVar<(@MHPVar/10), makered, nochange)}

Now, every time I use the score command in my mud it sets the value for the vbariable "MHPVar", and every time a line comes up that has the format <**hp **ma **mv> (where the *'s are numbers) it sets the value of CHPVar (these are resulting from other triggers).

So this trigger should make it so that if my CHPVar (current hps) is less than 10% of my MHPVar (max hps), then it should initiate the "makered" alias. The alias "makered" used to use the command "#COLOR 12". Now with zMUD version 6.4 or whatever it was that I was using before 6.62 (I'm pretty sure it was 6.4 something or other, I know it wasn't the 6.55 beta) this always worked right, it would make it so that the line "<**hp **ma **mv>" was bright red on a black background.

The problem I'm running into is that it doesn't seem to work anymore. I've tried making changes to the trigger to insert a command instead of the alias, I've tried different commands, I've tried changing the value of the alias so it initiated various different commands, but even with the trigger just as it is and with the alias set to a value of "#COLOR 12" this trigger isn't working right anymore :(.

I've always relied heavily on this trigger to warn me when I'm low on health and should consider fleeing so it's fairly important to me that I get it working right again. So here's my questions...

First, why does it not work anymore even when there are no changes and it used to work perfectly?

Second, is there a way to insert the #SUB command with the MXP <color> command into the place of the makered alias or into the value of the makered alias so that it will make the TEXT in the line a bold font with a dark red color (I've tried to do this as well but it hasn't worked, but since the trigger/alias seems to be failing anyway I'm not surprised at that)?

Also, I keep getting sytax errors reported anytime I use a # command within a parameter for another # command... i.e. if I use a #IF command for the first command initiated by a trigger and then try to set a # command as the command to make if the IF function is TRUE then I get a syntax error at the location of the second # symbol... do I have to replace those with a % symbol, or should I ignore the syntax error, or can I simply not use those types of commands, or what?

Any help is appreciated :)

Mordann
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed May 21, 2003 10:09 pm   
 
#TRIGGER {^~<(%d)hp %dma %dmv~>} {#IF (%1 < (@MHPVar/10)) {#COL red}}

You'll probably need to enable the Prompt option and disable the Newline option.

Since the hp info is included in the line, might as well make use of it. #IF is preferred for executing commands, functions are for returning values. Putting the color change in the trigger is probably more reliable than using a separate alias, since additional lines may arrive before the commands in the alias take place.

Why does a trigger not work that worked before?
Because zMUD has been changed. Change is necessary, since it's the only way to add, improve, or correct previous versions. To avoid problems from changes, it's best to stick to documented features and syntax as much as possible. This includes using ~ before all special characters in the pattern and using #IF to execute commands rather than %if.

The ANSI "bold" attribute is (by default) mapped to "Highlight color". To use a bold font, you'll have to remap it to "Bold font". You'll also need to be using a font with a bold version available. See Preferences, Colors, ANSI Mapping.

I don't recommend ignoring the syntax checker. It's similar to a spellchecker -- it's not always right, but in most cases it is. The previous problem was one of those rare cases where the syntax checker is wrong. It expects anything following # to be a zMUD command but in that case it was a hexcolor string. In this case, it's quite properly pointing out that commands don't belong inside functions.

LightBulb
Advanced Member
Reply with quote
Mordann
Beginner


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Thu May 22, 2003 7:28 am   
 
OK, I used the info you just gave to create the following trigger which works great, but I still couldn't get the #COLOR command to do custom RGB values right... trying to use them made it so the trigger didn't work at all...

Here's the trigger that works:

#TRIGGER {^~<(%d)hp (%d)ma (%d)mv~>} {#IF (%1 > (@MHPVar/2)) {#COLOR green};#IF (%1 <= (@MHPVar/2)) {#COLOR yellow};#IF (%1 <= (@MHPVar/4)) {#COLOR red};#IF (%1 <= (@MHPVar/10)) {#COLOR bold,red};#IF (%2 > (@MManaVar/2)) {#COLOR %2 green};#IF (%2 <= (@MManaVar/2)) {#COLOR %2 yellow};#IF (%2 <= (@MManaVar/4)) {#COLOR %2 red};#IF (%2 <= (@MManaVar/10)) {#COLOR %2 bold,red};#IF (%3 > (@MMovVar/2)) {#COLOR %3 green};#IF (%3 <= (@MMovVar/2)) {#COLOR %3 yellow};#IF (%3 <= (@MMovVar/4)) {#COLOR %3 red};#IF (%3 <= (@MMovVar/10)) {#COLOR %3 bold,red}}

In teh help file it says that RGB color values should be done in hex and preceeded by the "$" character when used with the #COLOR command. So I tried all of the following with various custom color hex values (we'll use "C0C0C0" as an example for now):

$C0C0C0
~$C0C0C0
#C0C0C0
~#C0C0C0

and all of them made it so that the trigger no longer worked at all.

I'm not worried about it because the above trigger with named colors works fine and the colors are just right anyway, but I wouldn't mind knowing what the story is on the custom colors with #COLOR just for satisfying my curiosity and possibly for future reference. So... Did I do something wrong? Did I misunderstand anything in teh help file? Does it just not work quite the way it's supposed to?

Well anyway, thanks for all the help :)

Mordann
Reply with quote
Mordann
Beginner


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Thu May 22, 2003 10:25 am   
 
OK, I was wrong, it didn't work... well, it sort of worked...

It did what I wanted it to do and dit it well, but it also had an unusual side-effect that I didn't expect (probably resulting from my lack of understanding of the zMUDScript language and teh script parser, but anyway...).

OK, so here's what happened...

The mud I play on reports your character's current hit points, mana points, and movement points everytime you send info to the server AND every time you recieve info FROM the server. This information is displayed on it's own line in the following format:

<100hp 100ma 100mv>

(assuming you actually had 100 hit points, 100 mana points, and 100 movement points at the time)

Now the trigger in my last post makes it so that all of the information, EXCEPT the actual number values for mana and movement, are colored according to the rules set forth by the #IF commands relating to "%1" (current value of hit points).

If current hit points is greater than 50% of the max hitpoints the character has (MHPVar) then the text is green. If current hp is 26%-50% of max then the color is yellow. If current hp is 11%-25% then the color is red. And if the current hp is 10% or less of the max then the color is red and teh font is BOLD.

The other commands in teh trigger change the color of the numbers relating to current mana and current movement... the formulas are teh same as those for hit points except that the result is that only the number corresponding to the stat in question is changed rather than the whole of the line.

Because of teh order in which the commands are given, it will change all text to the hp color, then it will change (if necessary) the text color for the mana number, and then lastly it will (if necessary) change the color of the text for the movement number.

All of this works properly and the current stats info report is colored properly in the output window (I tested it under several of the 64 possible conditions--I think it's 64 anyway).

The unexpected side-effect is as follows... Every time the trigger changes the color of teh numbers for either the mana or the movement, it automatically creates a NEW trigger. These triggers use the initial pattern of the number that the stat was at the time it's color was changed and they issue the command #CW "color name", where "color name" is the name of the color that the text was changed to (e.g. yellow).

So I've tried to think up new ways to write this trigger script, or even write several trigger scripts, so that it/they would accomplish the same effect except that they would NOT create the new triggers. I haven't succeeded yet, and again that's probably a result of my ignorance concerning teh zMUD script language and parser.

So then... Can anyone tell me why these new triggers are being created and what I could maybe do about it? As well as the trigger works otherwise I really don't want to make any major changes if I don't have to.

Would appreciate any help you can give, in teh meantime I'll just have to use

#TRIGGER {^~<(%d)hp %dma %dmv~>} {#IF (%1 > (@MHPVar/2)) {#COLOR green};#IF (%1 <= (@MHPVar/2)) {#COLOR yellow};#IF (%1 <= (@MHPVar/4)) {#COLOR red};#IF (%1 <= (@MHPVar/10)) {#COLOR bold,red}}

*sighs* I'm not learning this stuff nearly as quickly or as well as I'd like to :(. Oh well, I'll get it eventually (I hope so anyway).

Mordann
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu May 22, 2003 11:55 am   
 
The problem is that #COLOR and #CW create triggers when they have three arguments. They can have one of these two forms:
#CW pattern color

or:
#CW color

The first one is used outside of triggers (unless you really want to create a new coloring trigger from inside another trigger, which is not frequently done), while the second one is the one you use when you match something with a trigger and want to color it.

Now, your problems don't end there. What you want to do is not suited to be done with either #COLOR or #CW. You would have to use either #PCOL or #SUB. I'm guessing #PCOL will be somewhat complicated for this case, so you should use #SUB.

What you want to do is to build a string that will contain your new prompt using the rules for coloring. Then, you use #SUB to replace this string for your prompt. To build the string with the colors, use %concat and the MXP tags. Example:
#IF (%1 > (@MHPVar/2)) {#VAR lineCol "00FF00"};#IF (%1 <= (@MHPVar/2)) {#VAR lineCol "FFFF00"};#IF (%1 <= (@MHPVar/4)) {#VAR lineCol "880000"};etc.;#IF (%2 > (@MManaVar/2)) {#VAR manaCol "00FF00"};etc.;#IF (%3 > (@MMovVar/2)) {#VAR moveCol "00FF00"};etc.;#VAR newPrompt {%concat("~<color #", @lineCol, "~>~<", %1, "hp ~<color #", @manaCol, "~>", %2, "~</color~>ma ~<color #", @moveCol, "~>", %3, "~</color~>mv~>~</color~>")};#SUB {@newPrompt}

Kjata
Reply with quote
Mordann
Beginner


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Thu May 22, 2003 12:32 pm   
 
OK, I had something almost resembling an epiphany about this whole thing and came up with the following trigger:

**EDIT** I apologize, but with "Forum Code" turned on as it is the trigger code isn't displaying properly in the prieview so I'm removing it :(

OK, yes I realize that is a hell of a lot to chew through, and I'm sorry about that, but my question now is really somwhat simple (I think it is anyway). If my thinking is correct, and it may not be, but if it IS, then this trigger should do EXACTLY what I want to do with this whole stat reporting color stuff I've been talking about, and it will do so without the side-effect I mentioned in my last post. Unfortunately I haven't been able to test it because I know it isn't going to work right because the report of the variable values for @ColVar2B and @ColVar3B aren't reporting the correct characters. Namely, it reports the "~" characters, which should be reported, and IGNORES the "<" and ">" characters which I need to have present in the variable-expanded strings.

So my question (this time) is... Can I make it so that when the variable is expanded that it includes the string EXACTLY as it is preasent in the trigger, and if so, how? If I can't do it then I'll have to settle for my mana points and movement points numbers never being bold I think, but maybe I can figure it out *shrugs*

Once again, thanks for any and all help :)

**EDIT** IF I had been able to post the code and have it display correctly you would have more of an idea of what I'm doing, but basically I'm implementing a VERY complex system of subsequent #IF commands with #SUB commands for when the expression is true... It really comes down to this:

If certain conditions are met, set a variable to a value of a color and use teh #SUB command to replace teh line of text with the same text but in teh color of the variable...

If certain secondary conditions are met set a second variable with the value of a color and use teh #SUB command to replace most of teh text with the color of the first variable and part of teh text with the color of teh second one...

If certain tertiary conditions are met set a third variable, and use the #SUB command to replace most of the text with the first variable color, part with the second variable color, and part with the third variable color...

If certain other conditions are met, set the #SUB command to make the text a bold font.

I really wish I could get it to paste correctly... Is there anyway to make it so that my post does NOT use "Forum Code"?

OK, new idea, I'm uploading a text file with the code to http://shadow_dragons.tripod.com/PossibleStatsColorsTrigger01.txt, so it should be up in a few minutes and you can look at it there if you want to get a good idea of what I'm trying to do. I'd appreciate it if a few people WOULD look at it and try and help me :).

Mordann
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu May 22, 2003 1:03 pm   
 
quote:
The mud I play on reports your character's current hit points, mana points, and movement points everytime you send info to the server AND every time you recieve info FROM the server. This information is displayed on it's own line in the following format:
<100hp 100ma 100mv>


Yes, this is quite common. It's commonly referred to as a "prompt".

It's quite obvious that what you are trying to do is make it easy to visually judge your relative hps, mana, and moves. Another (perhaps simpler) idea for doing this is to leave the prompt the way the MUD sends it and add a graphic display of the information elsewhere. I generally use a set of gauges to display such information.

To create a HP gauge, you'll need your max hp's (@MHPVar) and your current hp's (@CHPVar). You can get the current hp's from the trigger you've already set up:
#TRIGGER {^~<(%d)hp (%d)ma (%d)mv~>} {#VAR CHPVar %1;#VAR CManaVar %2;#VAR CMoveVar %3) {} {nocr|prompt}

Gauges are a special form of Button, so click the Buttons button (I find all buttons are much easier to make in the editor than on the command line). To start a new button, click New. Select the Kind as Gauge. Give it a Caption, such as HP. Switch to the Gauge tab.

On the Gauge tab, set the Value to @CHPVar. Set the Gauge Max to @MHPVar. Set the Gauge Low to the value where you want the gauge to change color. I find max/4 gives me enough warning to be useful without occuring too often, so that would be @MHPVar/4.

Pick three colors, but don't use black (it's actually NO color, so it doesn't show up). I usually just change the Gauge Color to bright blue, and leave the Low Color as bright red and Gauge Backg as gray.

If you don't like the size/shape of the button, switch to the Position/Size tab. To change sizes, first unclick Auto Size. Then modify the values in Width and Height.

Similar gauges can easily be added for mana and moves.

These gauges only give you a two-color indicator, rather than four, but with the addition of the visual bar they are probably a better tool than the four-color prompt (and far less complicated). Give it a try and decide for yourself.

EDIT
-Since the trigger above is being used for a prompt, it should have the Prompt option enabled and the Newline option disabled. I've added the necessary options.
-Thanks for pointing out the use of $ instead of # for hexcolors inside the #COLOR command. You can add that to my earlier comments about using documented syntax.

LightBulb
Advanced Member
Reply with quote
Mordann
Beginner


Joined: 30 Mar 2003
Posts: 13
Location: USA

PostPosted: Thu May 22, 2003 11:58 pm   
 
OK, I missed Kjata's post this morning--I had been up for 20 hours or so and was tired and I was writting my latest post when Kjata's post was posted... anyway, I wasn't paying as much attention as I should have been and I missed it until this afternoon. So before I paid much attention to it I read LightBulb's last post as well and tried to decide what best to do.

I decided I didn't like the idea of guages because of their 2-color limit and the fact that I pay more attention to the text at the bottom of my zMUD output window than I do to the buttons and stuff around that window (most of the time I forget that my buttons even exist, let alone remember to look at them and use them). So I thought it would be better to figure out how to change the text colors and bold/not-bold fonts.

Kjata's post was EXTREMELY useful in that regard and I now have a trigger that works PERFECTLY (I only wish I had known of and understood the uses of the %concat function before *smiles happily*).

So now I have a trigger which successfully takes my prompt and resets its colors just as I had wanted them to do from the beginning. It's a little complex, but not nearly as complex as I expected it to be, and now it's working right I'm very happy :).

For anyone interested in looking at and possibly using the finished trigger, I uploaded it to here: http://shadow_dragons.tripod.com/promtcolors.txt :).

Thank you all SOOOOOOOO much for your help :)

Mordann
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