a color status bar

Posted by Faolong on Sat 26 Oct 2002 02:22 AM — 33 posts, 117,929 views.

USA #0
can we have a color status bar to indicate the levels of mana and hp and moves... etc.. it would be really useful if somebody wanted to replace the prompt line....
Australia Forum Administrator #1
I am working on that right now, as it sounds really useful.

In fact, I am doing a separate bar, so you can have the full width of the screen. This is planned to be a Rich Edit control, so you can have different colours, multiple fonts, bold, underline etc.
USA #2
Do you think you will add the ability to 'customize' the activity toolbar in the near future? For me at least, I'd like to be able to have one of the buttons link to an open notepad window within MC instead of only to world windows.

Actually.. what I'd like to do also is open existing notepad windows but open them within mushclient rather than outside MC.. I'm trying to spot somewhere on the menu to do that other than opening new ones.. can't seem to find it. Am I missing something? currently using vers 3.26 if that helps
Amended on Sun 27 Oct 2002 12:53 PM by Guest1
Australia Forum Administrator #3

OK then, this looks pretty exciting.

Version 3.29 onwards of MUSHclient will have a separate "info" bar, which is intended to show information relevant to what you are doing (eg. current status).

Here is an example:

The info bar is the width of the entire MUSHclient window, giving you lots of room to store things. In it you can have:

  • Multiple different fonts
  • Different colours (text colour)
  • Different font sizes and styles (eg. bold, underline)

By judicious use of symbol or special fonts (my example uses Webdings) you can draw gauges and similar things.

Australia Forum Administrator #4
This is the technique I used to do the above gauges. There is a DoGauge subroutine that draws individual gauges, and then a small trigger routine called by a trigger, which draws the three gauges ...


sub DoGauge (sPrompt, iCurrent, iMax, sGoodColour, sBadColour)
dim pc, count

'
'  Do prompt in black Arial
'
  world.InfoColour "black"
  world.InfoFont "Arial", 10, 0
  world.Info sPrompt

'
'  Use Webdings for gauge (black square)
'

  world.InfoFont "Webdings", 10, 0

  pc = CInt ((CInt (iCurrent) / CInt (iMax)) * 10)

'
'  Below 20% warn by using different colour
'

  if pc < 2 then
    world.InfoColour sBadColour
  else
    world.InfoColour sGoodColour
  end if

'
'  Draw active part of gauge
'
  for count = 1 to pc
    world.Info "g"
  next  

'
'  Draw rest of gauge in grey (ie. unfilled bit)
'

  world.InfoColour "dimgray"
  while count < 10
    count = count + 1
    world.Info "g"
  wend

end sub

sub DoPrompt (sName, sLine, wildcards)

  world.InfoClear

'
'  World name
'

  world.InfoFont "Arial", 12, 1  ' 12 point Arial *bold*
  world.InfoColour "purple"
  world.Info world.GetInfo (2)  ' world name

  DoGauge "  HP: ", wildcards (1), wildcards (2), "darkgreen", "maroon"
  DoGauge "  Mana: ", wildcards (3), wildcards (4), "mediumblue", "mediumblue"
  DoGauge "  Move: ", wildcards (5), wildcards (6), "gold", "gold"

end sub

Amended on Sun 27 Oct 2002 09:51 PM by Nick Gammon
USA #5
Hmm. Nice.. Now just patching my own code for the Hitbar in so you can use some code and a function from my HitBar plugin at www.magnumsworld.com/muds:

pc = CInt ((CInt (iCurrent) / CInt (iMax)) * 10)
Hue = 120 * pc
Sat = 255
Lumin = 60 * pc + 68
color = HSLtoRGB(Hue, Sat, Lumin)

DoGauge " HP: ", wildcards (1), wildcards (2), color, "maroon"

and it will be even nicer. ;) In fact it may be a lot better than even the one I built. Especially since mine is specific to Ages of Despair. Is the bar resizable? Like if you have a 'lot' more stuff than will fit on one line easilly?
Amended on Sun 27 Oct 2002 11:20 PM by Shadowfyr
Australia Forum Administrator #6
Can't make that work right now, so for now we'll have a single-line one. :)

I suggest if you have a lot more than one line use a notepad window instead.
Amended on Mon 28 Oct 2002 02:54 AM by Nick Gammon
USA #7
Hmm. Ok.. Maybe later. As for the notepad idea.. That is relaively useless for the kind of stuff I would like to put on such a bar. lol
Poland #8
I have idea :-)

Is this possible to resize status bar? I mean to change location to anywhere of my screen and to change size to more than one line.

Ovvi
Australia Forum Administrator #9
If you click on the left-hand edge of it you can drag it to:

  • Dock at the top of the window
  • Dock at the bottom of the window
  • Make a floating window


I just noticed then that if you release it in the middle of the main window the entire window seems to go grey, so my advice is -- don't do that.
Greece #10
You have a slight bug there :) Oh, by the way, until you can ge webdings to work, just change "g" to "l". Looks almost like a status bar. "#" is nice too.
Anyway, sometimes, when you remove your equipment, you have more hp/mana/move than your max, and in that case the bar expands. you should put this line there:

'The next line is the one to use.

if pc > 10 then pc = 10

for count = 1 to pc
world.Info "l"
next
#11
Here's something I threw together to make a single function that maintains all the info bar data in a good order. It is especially useful if you want to use data from several different places but keep everything in a consistant order.

The programming looks pretty nasty, but it works pretty well.

I ended up using arial narrow with the letter "l" to do the bars since it was smaller and could get more on in the same space for slightly more accurate monitoring.

The only required variable is info_data, and only required code outside of the primary function is the ReDim info_data(2). Everything else is included for demonstration purposes only.

Dim info_data
Dim hpbar_hp
Dim hpbar_hp_max
Dim hpbar_hp_perc
Dim hpbar_sp
Dim hpbar_sp_max
Dim hpbar_sp_perc
Dim hpbar_extra1
Dim hpbar_extra2

ReDim info_data(2)
' These should be set in triggers, here's some data to play with though
hpbar_hp = 75
hpbar_hp_max = 100
hpbar_sp = 25
hpbar_sp_max = 125

hpbar_hp_perc = Fix((hpbar_hp * 100) / hpbar_hp_max)
hpbar_sp_perc = Fix((hpbar_sp * 100) / hpbar_sp_max)

' If you have multiple entries, set them up first so it knows your preferred order
write_info "hp_bar", ""
write_info "hp_bar2", ""

' Change data in any order, it will keep them in the same order from when you first requested each
write_info "hp_bar2", "@color:black@@font:arial/10/0@Extra: " & hpbar_extra1 & "/" & hpbar_extra2
write_info "hp_bar", "@color:black@@font:arial/10/0@HP: @bar:25/" & hpbar_hp_perc & _
    "/red/gray@@color:black@@font:arial/10/0@  SP: @bar:25/" & hpbar_sp_perc & _
    "/blue/gray@"


' @font:name/size/stylecode@
' @color:name@
' @bar:length/percentage/coloron/coloroff@

' 2 spaces between each section
Sub write_info(ByVal strType, ByVal strData)
  Dim i
  Dim split_data
  Dim j
  Dim str1
  Dim str2
  Dim k
  Dim strBar
  Dim l
  Dim m

  For i = 1 To UBound(info_data) Step 2
    If (strType = info_data(i)) Then Exit For
  Next

  If (i > UBound(info_data)) Then
    i = UBound(info_data) - 1
    If (info_data(1) <> "") Then
      i = i + 2
      ReDim Preserve info_data(i + 1)
    Else
      i = 1
    End If
  End If

  info_data(i) = strType
  info_data(i + 1) = strData

  world.InfoClear
  For i = 1 To UBound(info_data) Step 2
    split_data = Split(info_data(i + 1), "@")
    For j = 0 To UBound(split_data)
      If (j Mod 2 = 0) Then
        If (split_data(j) <> "") Then world.Info split_data(j)
      Else
        str1 = Split(split_data(j), ":")(0)
        str2 = Split(split_data(j), ":")(1)
        Select Case (str1)
          Case "font"
            If (UBound(Split(str2, "/")) <> 2) Then
              world.Note "-----"
              world.Note "write_info : Error in font data - '" & str2 & "'"
              world.Note "-----"
              Exit For
            End If
            world.InfoFont Split(str2, "/")(0), CInt(Split(str2, "/")(1)), CInt(Split(str2, "/")(2))
          Case "color"
            world.InfoColour str2
          Case "bar"
            If (UBound(Split(str2, "/")) < 3) Then
              world.Note "-----"
              world.Note "write_info : Error in bar data - '" & str2 & "'"
              world.Note "-----"
              Exit For
            End If
            strBar = ""
            For k = 1 To CInt( Split(str2, "/")(0) )
              strBar = strBar & "l"
            Next
            world.InfoFont "Arial Narrow", 11, 1
            world.InfoColour Split(str2, "/")(2)
            l = CInt( Split(str2, "/")(1) )
            If (l > 100) Then
              l = 100
            ElseIf (l < 0) Then
              l = 0
            End If
            m = CInt( Split(str2, "/")(0) )
            k = Round( m * l / 100 )
            world.Info Left(strBar, k)
            world.InfoColour Split(str2, "/")(3)
            world.Info Left(strBar, m - k)
        End Select
      End If
    Next
    world.Font "arial", 10, 0
    world.Color "black"
    world.Info "  "
  Next


  Set strType = Nothing
  Set strData = Nothing
  Set i = Nothing
  Set split_data = Nothing
  Set j = Nothing
  Set str1 = Nothing
  Set str2 = Nothing
  Set k = Nothing
  Set strBar = Nothing
End Sub
USA #12
Hello all.
Uhmm nice examples of the hitbars Mr Gammon, Vaejor and Shadowfyr. BUt i only have one thing to ask.. WHat are the triggers for them. Nobody gives the proper triggers to use for their scripts. So if you could PLEASE give examples of the triggers too. It'd be greatly appreciated, Thanks..
A confused Wulph
Stefan Wulph
USA #13
Well StefanWulph.. In the case of my suggestion, it requires two subroutines in VBScript that are part of my own version of such a bar. The triggers I use for mine are included within that plugin, which you can download from www.magnumsworld.com/muds.

However, since I don't use the infobar itself, but generate my own inline bar, most of the code wouldn't help much. It is a good source of examples for the trigger I use. If you do want to use the HSLtoRGB(Hue, Sat, Lumin) feature to adjust the color by percentage it is a must though, since Mushclient has no such converter built into it.

Put simply. You could either adapt the trigger and text it displayed to match the line you want to replace and use it as is, or use the trigger and HSLtoRGB code and scrap the rest in favor of something that used the InfoBar. ;) Since I already had mine working, and I had some issues with the way the InfoBar works, I never bothered to code a version that used it.


However, to more specifically answer you, the trigger I am using works off a lines like:

HP: [50/100] CONC: [100/400]
HP: [50/100] CONC: [100/400] Opponent: Wounded

So my trigger looks like this:

<trigger
   enabled="y"
   match="HP: [(.*)/(.*)]  CONC: [(.*)/(.*)](.*)"
   name="HitBar"
   omit_from_log="y"
   omit_from_output="y"
   sequence="1"
   regexp="y"
   script="HealthDisp"
  >
</trigger>


I chose to use a regular expression to avoid some of the issues that could come up otherwise. Hmm... Although, I should have used match="^HP: [(\d+)/(\d+)] CONC: [(\d+)/(\d+)](.*)" in order to avoid it working on stuff someone dropped in channels and to make sure that 'HP: [1/3]' worked, but 'HP: [a/b]' wouldn't. But that would be overkill, just adding the ^ to it would fix the channel spoofing issue. ;)

In simplest terms you could manage with:

<trigger
   enabled="y"
   match="HP: [*/*]  CONC: [*/*]"
   name="HitBar"
   omit_from_log="y"
   omit_from_output="y"
   sequence="1"
   script="HealthDisp"
  >
</trigger>

sub HealthDisp (name, output, wilds)
  pc = CInt ((CInt (wilds(1)) / CInt (wilds(2))) * 10)
  Hue = 120 * pc
  Sat = 255
  Lumin = 60 * pc + 68
  color = HSLtoRGB(Hue, Sat, Lumin)
  DoGauge " HP: ", pc, 100, color, "maroon"

  pc = CInt ((CInt (wilds(3)) / CInt (wilds(4))) * 10)
  Hue = 120 * pc
  Sat = 255
  Lumin = 60 * pc + 68
  color = HSLtoRGB(Hue, Sat, Lumin)
  DoGauge " HP: ", pc, 100, color, "maroon"
end sub

'Color spectrum is:
'  0 = Red
' 60 = Yellow
'120 = Green
'180 = Cyan
'240 = Blue
'300 = Magenta
'360 = Red

function HSLtoRGB (Hue, Sat, Lum)
  dim rm1, rm2, Temp, Temp2, Red, Green, Blue
  Lum = Lum / 255 '** Get these back to a %. Hue is an arc from 0 to 360, so we don't touch it.
  Sat = Sat / 255
  if Sat = 0 then
    Temp = Lum * 255 '** Satuaration of 0 means it is gray, so all colors are a % of the maximum.
    Red = Temp
    Green = Temp
    Blue = Temp
  else
    if Lum <= 0.5 then '** Haven't a clue about the rest of this, I just know it works. lol
	rm2 = Lum + Lum * Sat
    else
	rm2 = Lum + Sat - Lum * Sat
    end if
    rm1 = 2 * Lum - rm2
    Temp = rm1
    Red = FindColor(Temp, rm2, Hue + 120)
    Temp = rm1
    Green = FindColor(Temp, rm2, Hue)
    Temp = rm1
    Blue = FindColor(Temp, rm2, Hue - 120)
  end if
  Red = Cint(Red) '** Stick it all together into a single hex string.
  Temp = Hex(Red)
  if len(Temp) < 2 then
    Temp = "0" + Temp
  end if
  Temp2 = Temp
  Temp = Hex(Green)
  if len(Temp) < 2 then
    Temp = "0" + Temp
  end if
  Temp2 = Temp2 + Temp
  Temp = Hex(Blue)
  if len(Temp) < 2 then
    Temp = "0" + Temp
  end if
  Temp2 = Temp2 + Temp
  HSLtoRGB = Temp2
end function

function FindColor (rm1, rm2, rh)
  if rh > 360 then
    rh = rh - 360
  else
    if rh < 0 then
	rh = rh + 360
    end if
  end if
  if rh < 60 then
    rm1 = rm1 + (rm2 - rm1) * rh / 60
  else
    if rh < 180 then
	rm1 = rm2
    else
	if rh < 240 then
        rm1 = rm1 + (rm2 - rm1) * (240 - rh) / 60
      end if
    end if
  end if
  FindColor = rm1 * 255
end function


That would produce two guages based of the current and maximum values for HP and CONC that change color as those stats dropped. Yours would be different of course, but this is basically all that is needed to do so. Assuming I didn't screw something up that is. ;)
Amended on Mon 03 Feb 2003 08:33 AM by Shadowfyr
Australia Forum Administrator #14
I didn't show the actual trigger because it would depend a great deal on the prompt, and it was pretty simple, you just need 6 wildcards for HP/Total HP, Mana/Total mana, Move/Total move.

eg. something like this:

If the prompt was:

<80/10 hp 10/50 m 30/80 mv>

Then your trigger would be:

<*/* hp */* m */* mv> *

The final * would be the rest of the line, eg. your command.
Amended on Mon 03 Feb 2003 09:04 AM by Nick Gammon
USA #15
hmm.. do you play on SlothMUD III by any chance Nick?

btw any release date on 3.33 as yet, now that it's February?
Australia Forum Administrator #16
No, but a lot of their prompts are similar.

I am working on 3.33 now, shouldn't be too long. :)
USA #17
yay :)
USA #18
Oh, This is just sexy....

I'd really like to set this up for the Current mud I'm playing...

Its called Xaos, its Addy is Xaos.ath.cx:5000

Its got 3 modes of play, HCRP mode is the ultimate mode of playing, Now I love how this color display works in the info bar

Unfortunately there is no #/# HP

Instead it gives you the % of your HP

I.E. 100% HP, 80%HP and so on and so forth.

Can this be modified to work with that?
USA #19
I figured I'd post again, and show you what my prompt is exactly so you might be better able to understand what would need to be done

<100%HP 100%Mana>
<100%Move 0-100%TNL>

This ofcourse can be changed to anything I want in any configuration.

I'd imagine the way you'd want to setup the trigger would be something Similar to this.

Now, about the EXP part, I was thinking instead of a bar like HP and Mana and Move

It could just be numbers... Right now it counts from 0 up to 100% experience towards level.

I'd somehow like to make it count from 100% down to 0%, then when I level it starts @100% again.
I'd Imagine I would change my prompt to:
<100%HP 100%Mana 100%move 0-100%TNL>

Thanks... BTW I changed email addresses, I used to be Just Plain David, and I didn't want to take the time to email support and what not so I just made a new account :/
USA #20
I figured I'd post again, and show you what my prompt is exactly so you might be better able to understand what would need to be done

<100%HP 100%Mana>
<100%Move 0-100%TNL>

This ofcourse can be changed to anything I want in any configuration.

I'd imagine the way you'd want to setup the trigger would be something Similar to this.

Now, about the EXP part, I was thinking instead of a bar like HP and Mana and Move

It could just be numbers... Right now it counts from 0 up to 100% experience towards level.

I'd somehow like to make it count from 100% down to 0%, then when I level it starts @100% again.
I'd Imagine I would change my prompt to:
<100%HP 100%Mana 100%move 0-100%TNL>

Thanks... BTW I changed email addresses, I used to be Just Plain David, and I didn't want to take the time to email support and what not so I just made a new account :/
Australia Forum Administrator #21
If you have a percentage, that makes it slightly simpler. The bar drawing subroutine was working the percentage out, like this:



pc = CInt ((CInt (iCurrent) / CInt (iMax)) * 10)

If you already know the percentage then you just need to use that. I was multiplying by 10 so that (say) 50% would be 5 "bars", so if you already have a percentage (from 0 to 100) you would *divide* by 10, so that 50% is still 5 bars.

USA #22
Oh ya, its only 0-100%

I'd appreciate it if someone could email me the working bar code, or even put it in a pluggin for me, I'd be eternally grateful.

This seems REALLY complicated for me to code, if someone wanted to walk me through it via email, or just email me the code, that'd be great.

Morpheus1040@attbi.com
#23
Alright, I've never before done anything more advanced than variables using mushclient, so I was wondering if anyone could help me here. I want to have something like what has been posted here, but my prompt is a little bit different. Here is an example:
2072h, 2734m ex-
Yes, that's Achaea, and i'm pretty sure posting a script for this will help out a lot of the many players.
Australia Forum Administrator #24
If the prompt is slightly different, just change the trigger to match. eg. if the prompt is:

2072h, 2734m ex-

The trigger might look like:

*h, *m ex-
#25
Alright, Nick, I tried that and it didn't work. This is exactly what I have on my script, if anyone could please tell me what's wrong it'd be very helpful. Thanks.

sub DoGauge (sPrompt, iCurrent, iMax, sGoodColour, sBadColour)
dim pc, count

<trigger
enabled="y"
match="^(.*?)h\, (.*?)m (.*?)\-$"
name="InfoBar"
omit_from_log="y"
omit_from_output="y"
sequence="1"
regexp="y"
script="InfoBar"
>
</trigger>
world.InfoColour "black"
world.InfoFont "Arial", 10, 0
world.Info sPrompt

world.InfoFont "Webdings", 10, 0

pc = CInt ((CInt (iCurrent) / CInt (iMax)) * 10)

world.InfoColour "red"

if pc < 2 then
world.InfoColour sBadColour
else
world.InfoColour sGoodColour
end if


for count = 1 to pc
world.Info "g"
next



world.InfoColour "dimgray"
while count < 10
count = count + 1
world.Info "g"
wend

end sub

sub DoPrompt (sName, sLine, wildcards)

world.InfoClear

Achaea

world.InfoFont "Arial", 12, 1 ' 12 point Arial *bold*
world.InfoColour "purple"
world.Info world.GetInfo (2) ' world name

DoGauge " HP: ", wildcards (1), wildcards (2), "darkgreen", "maroon"
DoGauge " Mana: ", wildcards (3), wildcards (4), "mediumblue", "mediumblue"
DoGauge " Move: ", wildcards (5), wildcards (6), "gold", "gold"

end sub
Australia Forum Administrator #26
I don't quite understand the appearance of the XML trigger text in the middle of the script, nor all those question marks.
Canada #27
Nick, I don't see question marks in his post, but rather some wierd special character.

At any rate, Enkidu, your posting seems to indicate that your script is not formatted properly.

The break lines of special characters do not appear to have an comment character (Which is a single quote in VBS) at the beggining of the line. Those lines will cause syntax errors when you attempt to load your script.

The XML style quote of your trigger does not belong directly in your script in this manner, as you have posted it. If this project is built within the main environment of your world file, the triggers should be assembled in the trigger configuration screen. If you are using the "copy" feature to copy the "code" of the trigger, then you should post it at the beginning or end of your forum posting so we know that you have built it correctly.

(You've got it smack in the middle of your script, which would cause errors if this is actually a direct quote of your script file)

Plugin files are different, in that you would embed the trigger code directly in the file... However, if this is the case, there are other XML tags required to properly format the file. That is, triggers are marked by their <trigger> and </trigger> tags. Your script would also need to be contained within <script> and </script> tags.

Please refer to the sample .VBS script file and the plugins that come with MUSHclient, for examples of how those files should be formatted.
USA #28
I'm greatly new to this world of programming, I'm using the infobar supplied here in this thread by Nick, and I'm running into a bit of trouble trying to modify it to work for my mud. My mud supplies these lines which i have made triggers for
HP: 124/142, SP: 116/142
HP: */*, SP: */* is my trigger
and
You are alchemist level 54, with 5,152,064 guild exp (335,436 more needed).
Your are alchemist level 54, with * guild exp (* more needed). is my trigger

the problems I've run into are that the HP/SP doesnt work for my max if i'm at 124 hp the bar shows full and if i'm below 2% it doesnt show up in the bad color
and I want to add on a bar for my gxp to show a % of how close I am to the next level where 100% would be the next level mainly I think it's the ','s that are giving me the biggest trouble, any suggestions or help would be me nice
thank you
Australia Forum Administrator #29
The status bar draws a "bar" by drawing between 0 and 10 little boxes in a different font. The calculation bit is here:

pc = CInt ((CInt (iCurrent) / CInt (iMax)) * 10)

Now 124/142 is 0.87 times 10 = 8.7 which will probably draw 9 boxes. This shouldn't be "full" as I thought full would be 10 boxes, however maybe it looks full.

Similarly 2% would be less than one box, so you don't see any red. Maybe you should add a test, that if there is < 1 box always show one red box.

As for the commas, you need to get rid of them. Something like this:

dim num

num= wildcards (1)
num = CInt (world.Replace (num, ",", ""))

The Replace command will replace commas with nothing, and then you use CInt to convert the result to a number.
Australia Forum Administrator #30
I have made a Health Bar plugin to show the general idea - see the plugins page for details.
USA #31
thank you Nick, also I'm not sure how VB works, but doesn't this only go to 9
while count < 10
count = count + 1
world.Info "g"
wend
I changed it to 11 and it seems to be working fine, as far as the % to guild level i'm still working that issue.
Thanks again
Australia Forum Administrator #32
You are right, it only showed 9 bars. I have amended the plugin to be <= 10 (< 11 would be the same thing).

I also amended it to go from 0 to 10 (11 bars) because there was an earlier comment that very low health did not show in red. Now, you will always see at least one bar, which means if it is red, you still see one red block. I think this is easier to spot.