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 Posted: Wed May 21, 2003 12:24 am
MXP color text replacements question...
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