Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Need help with color trigger, it will trigger but only the 2nd time

Need help with color trigger, it will trigger but only the 2nd time

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Zuurstof   (13 posts)  Bio
Date Fri 13 Dec 2002 12:59 PM (UTC)
Message
Hi, I've been having a little problems with a trigger that I am using.

I want to color my hp/ep bar with different colors for each item, the bar looks as following

HP:100 EP:100

But it could also look like if somebody entered a lot

HP:100 EP:100 HP:100 EP:100 HP:100 EP:100 HP:100 EP:100 etc.

Now my problem is that every time I enter a command into the it shows that bar, and the trigger should color it.

Well this does work but it does not seem to process that last new line send to my computer. I've added an notice so you can see where the trigger triggers
Example:

First I connect and it shows

Reconnected.
HP:100 EP:100 Gentle plains extend in every direction around you.

And that's it, no trigger
Then I press 'l' and get a description of my surrounding and after every command you get to see your hp/hp bar again.
Looks like this.

HP:100 EP:100 Gentle plains extend in every direction around you.
(* This is the trigger notice! *)
The grass ....blah blah blah
The only obvious exits are east, south, west and north.
HP:100 EP:100

So now you did see it trigger, but it only trigger for the first hp/ep bar, not the 2nd. It should like this.

HP:100 EP:100 Gentle plains extend in every direction around you.
(* This is the trigger notice! *)
The grass ....blah blah blah
The only obvious exits are east, south, west and north.
HP:100 EP:100
(* This is the trigger notice! *)


So in my eyes it looks like everything works but it will only process a line when a newline is given or something.
Is anybody familiar with this problem let me know, it's really puzzling me.
Top

Posted by Zuurstof   (13 posts)  Bio
Date Reply #1 on Fri 13 Dec 2002 01:10 PM (UTC)
Message
This is kinda related question, I might as well post it here. I want to make a script that grabs my hp/ep

HP:107 EP:69

send those numbers(random) 107 and 69 to that script
so it can process it in a case statement, then I want it
to color hp ranging from 150 to 230 changing to green, 50 to 150 changing to orange and 0 to 50 changing to red for instance. the same goes for ep.

I have no real idea how to do this do, I think it might have something to do with adding new color triggers for .EP... and .HP... but then I hit on the problem above:)

As you can see, I have quite a few problems:)

I hope somebody here can be of assistance, I coudn't find very much other sources about this on the web.

Greetings Zuurstof

Feel free to mail if you know anything about it.
Top

Posted by Shadowfyr   USA  (1,790 posts)  Bio
Date Reply #2 on Fri 13 Dec 2002 07:03 PM (UTC)
Message
This is an issue with prompts. If you can medify your prompt to add a newline each time it shows up, then it will be fixed. Otherwise, mushclient has no way of knowing that the information recieved it not simply a partial line, with the rest of it to follow in the next batch of data. It identifies individual lines only when recieving a newline.

There is a post on here about getting things like your hit points, etc. using a timer and some other tricks, but on muds that insist on spamming your screen with stuff like 'HP:100 EP:100 HP:100 EP:100 HP:100 EP:100 HP:100 EP:100', instead of real lines, there is not a lot that can be done about it. imho This is a stupid way to do things, since you end up needing to use something like '*HP:* EP:*' or 'HP\:(\d+) EP:\:(\d+)' to retrieve the info and such tests would be unable to tell the difference between the following:

HP:50 EP:100
Sam tells you: Mine is HP:30 EP:70
[some channel] Fred: Almost died - HP:1 EP:60

This could also be intentional, so as to prevent anyone from using such triggers, though it is a real ugly way to do it if that is the case.
Top

Posted by Shadowfyr   USA  (1,790 posts)  Bio
Date Reply #3 on Fri 13 Dec 2002 07:47 PM (UTC)
Message
Hmm. For the second bit you ask about.. There is a minor problem in that your status doesn't provide a current/maximum type display. However, I have a plugin that could be addapted to such a use posted at Magnum's site 'www.magnumsworld.com/muds'.

It uses a method by which you have a minimum and maximum color hue, say 120-0 and you can do something like:

t2 = int(58 * (perc/100)) + 100
t1 = int(120 * (perc/100)) '** This one starts at green and goes down.
wfore = HSLtoRGB(t1, 255, t2)
world.notecolour wfore, "black", "HP: " & Myhp

and

t2 = int(58 * (perc/100)) + 100
t1 = 360 - int(120*(perc/100)) '** This one starts at blue and goes up.
wfore = HSLtoRGB(t1, 255, t2)
world.notecolour wfore, "black", "HP: " & Myhp

where 'perc' is the current percentage of your maximum color. In this case the first calc runs from 120 to 0, which is green, through yellow, orange, then red on the hue chart, while the second runs from 240 to 360 (blue to purple, to violet, to red). It also uses the percentage to find the luminosity (brightness), so that the colors run from full brightness to very dark. As long as you keep track of the maximum HP or EP you can have all you need is the above calculations and the two routines HSLtoRGB and FindColor to get get the correct color in the range you are using.

Note: The calls to HSLtoRGB above use (hue, saturation, brightness). The 255 means that the color is 'pure', while lower values add increasing amounts of gray. A value of 0 means it will be pure gray, even if the color you tell it to use is orange. Using a value for brightness above 128 can effect the way a color looks too, making the color brighter, but increasingly bleached. This is because white = hue 0, saturation 0, luminosity 255. So you can think of increasing the brightness as adding white to paint and decreasing it to be like adding black.

Basically for you.. You would want to find the full HP you can have and store that in a variable, then once you find a way to actually get the lines (which is not likely unless you can change your prompt), you would omit the line while grabbing the contents, then in a script you would retrieve the variable for the maximum, get a percentage:

perc = int(100 * (current/maximum))

and use that to find the values to call HSLtoRGB. ;)

The benefit to doing it this way is that you only have to decide what color to start at and what to end on, then let the script give it to you. ;)

The color wheel (more or less)>

Red ........ 0
Red-Orange . 30
Orange ..... 40
Gold ....... 50
Yellow ..... 60
Green ...... 80<>150 (120 is considered 'green')
Aqua ....... 170
Baby Blue .. 190
Blue ....... 240
Purple ..... 280
Magenta .... 300
Hot Pinks .. 310<>330 (more and more red)
Reds ....... 340+
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.


12,457 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.