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, 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.
 Entire forum ➜ MUSHclient ➜ Tips and tricks ➜ New custom status bar window

New custom status bar window

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


Pages: 1  2 3  4  

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #15 on Tue 30 Nov 2004 10:45 PM (UTC)
Message
Ah no, I was just pointing out that mine was also free. This is great, now we can make clients communicate in previously unimaginable ways!

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Nick Gammon   Australia  (23,072 posts)  Bio   Forum Administrator
Date Reply #16 on Tue 30 Nov 2004 10:47 PM (UTC)
Message
Quote:

Which also leads me to think, which plugin of which world would receive the packet? They could all get it and then choose if they want it, but I'll leave that up for discussion.


I didn't want this idea to go crazy, it remembers which plugin installed the listener, and that one gets it. However you could have multiple plugins that listen on different ports.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #17 on Tue 30 Nov 2004 10:50 PM (UTC)
Message
Oh, I see. Well, there are 65000 ports, so it'll take a while for someone to bump into two plugins that use the same port. Does it return an error if another application is listening to the port, or does UDP allow that? I'm a bit rusty on it, but that could account for erratic behaviour. The best way is for the plugin writer to prefix each text they send with the plugin's name or another string and discard everything else.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #18 on Tue 30 Nov 2004 10:57 PM (UTC)
Message
eBadParameter: The port is already in use by another plugin, or the UDP socket could not be created

Returns that if being used elsewhere.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Nick Gammon   Australia  (23,072 posts)  Bio   Forum Administrator
Date Reply #19 on Tue 30 Nov 2004 10:58 PM (UTC)

Amended on Wed 01 Dec 2004 04:29 AM (UTC) by Nick Gammon

Message
Well, you can go further than that. ;)

Here is what I have tried. First make a little plugin that displays the incoming packets:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, November 30, 2004, 3:15 PM -->
<!-- MuClient version 3.56 -->

<!-- Plugin "udptest" generated by Plugin Wizard -->

<muclient>
<plugin
   name="udptest"
   author="Nick Gammon"
   id="03f4d34b49652923953d9c19"
   language="VBscript"
   purpose="testing udplisten"
   date_written="2004-11-30 15:13:41"
   requires="3.56"
   version="1.0"
   >

</plugin>


<!--  Script  -->


<script>
<![CDATA[
sub GotPacket (which)
  ColourTell "white", "green", which
end sub

sub OnPluginInstall ()
 status = UdpListen ("0.0.0.0", 4222, "GotPacket")
 if status <> 0 then
    ColourNote "white", "red", _
      "UdpListen not installed, error code " & status
 else
    ColourNote "white", "darkgreen", "UdpListen installed"
 end if
end sub
]]>
</script>


</muclient>



Now go to a different PC (or the same PC, or whatever) and pipe a Unix command to your MUSHclient PC...


 ls | ./udpsend 10.0.0.3 4222


Then you see the directory listing on your MUSHclient world. Now you can see various possibilities here. You might have something installed on your MUD server box (maybe hosted at a different site) and that could send you a UDP packet if, say, the disk is filling up, or the server has crashed, or whatever.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,072 posts)  Bio   Forum Administrator
Date Reply #20 on Tue 30 Nov 2004 11:11 PM (UTC)
Message
Tests would seem to indicate that multiple copies of the status bar listening on the same port on a particular PC will not necessarily all get the message. So if you want to have multiple ones (eg. an inventory, and a health bar) choose different ports.

You can specify the port when you run the statusbar program:


StatusBar port ip magic

eg.

StatusBar 4222 0.0.0.0 gandalf



However if you broadcast, the same message can appear on different PCs. For example in my network I have a private IP address range 10.0.0.1 onwards. If I use the udpsend program to send to 10.0.0.255 then all PCs listening on that port get the packet at the same time (roughly).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,072 posts)  Bio   Forum Administrator
Date Reply #21 on Wed 01 Dec 2004 04:33 AM (UTC)
Message
Also, tests have shown that re-installing the plugin seems to fail every second time. It would appear that re-using the port in quick succession causes an "address in use" message from the Windows sockets. You normally wouldn't do that anyway, once you have the plugin installed it would stay there.

However I amended the plugin code above to show an error message, so you can see if it installed or not.

If you really need to reinstall it, I would suggest using some technique to remove the old listener, wait a second, and then install a new one.

eg.


'
'  remove the old one
'

UdpListen ("0.0.0.0", 4222, "")

'
'  use a timer here to wait a second  
'

' ------ timer delay ------

'
'  install the new one
'

UdpListen ("0.0.0.0", 4222, "GotPacket")


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Afkeraeon   (7 posts)  Bio
Date Reply #22 on Thu 16 Dec 2004 07:13 PM (UTC)
Message
Soooo, how do you make the statusbar react to changes in the mud? I don't have a clue about how to make MC send UDP packets. Also, the MUD I play on has this nifty thing for MXP. First it sends this:

<STAT MUD_HP MAX=MUD_MAXHP CAPTION=" HP: ">
<STAT MUD_SP MAX=MUD_MAXSP CAPTION=" SP: ">
<STAT MUD_EP MAX=MUD_MAXEP CAPTION=" EP: ">
<STAT MUD_MONSTER_NAME CAPTION=" Monster Name: ">
<STAT MUD_MONSTER_HEALTH CAPTION=" Monster Health: ">
<STAT MUD_ACTION CAPTION=" Action: ">
<!ENTITY MUD_MAX_MON_HEALTH 100 PUBLISH>
<GAUGE MUD_HP MAX=MUD_MAXHP caption=HP>
<GAUGE MUD_SP MAX=MUD_MAXSP caption=SP>
<GAUGE MUD_EP MAX=MUD_MAXEP caption=EP>
<GAUGE MUD_MONSTER_HEALTH MAX=MUD_MAX_MON_HEALTH caption=MONSTER>

Then every tick after, it sends this:

<!ENTITY MUD_HP 1534 PUBLISH>
<!ENTITY MUD_MAXHP 1534 PUBLISH>
<!ENTITY MUD_SP 2687 PUBLISH>
<!ENTITY MUD_MAXSP 2687 PUBLISH>
<!ENTITY MUD_EP 1207 PUBLISH>
<!ENTITY MUD_MAXEP 1207 PUBLISH>
<!ENTITY MUD_MONSTER_NAME "" PUBLISH>
<!ENTITY MUD_MONSTER_HEALTH 0 PUBLISH>
<!ENTITY MUD_ACTION "" PUBLISH>

Would this be possible to use to make a MXP thing or script which updates the bars manually? :)
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #23 on Thu 16 Dec 2004 08:52 PM (UTC)
Message
You can use GetEntity (http://www.gammon.com.au/scripts/function.php?name=GetEntity) to get all the values, which you can then send to the bar/window/whereever.

The first part looks like it just sets up the bar area, and then the second actually has all the info. So you could do something similar in the window. You'd just need a trigger that gets sent with the MXP info (the tick perhaps?) to set off the update. Does the info get sent before or after the tick?

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Nick Gammon   Australia  (23,072 posts)  Bio   Forum Administrator
Date Reply #24 on Fri 17 Dec 2004 (UTC)
Message
After a bit of mucking around I got a timer to do it, like Flannel suggested. I did it in Lua, so either switch your scripting to Lua, or make a plugin out of it. If you have trouble doing that let me know and I'll do one.

I decided it was easier to hard-code the names of each bar rather than trying to interpret the STAT and GAUGE MXP elements, which MUSHclient doesn't currently support.


<timers>
  <timer enabled="y" second="5"    send_to="12"
>
  <send>do

t = t or {}
local old_t = {}

-- make copy of current values
for k, v in t do
  old_t [k] = t [k]
end

t.mud_hp = GetEntity ("mud_hp")
t.mud_maxhp = GetEntity ("mud_maxhp")
t.mud_sp = GetEntity ("mud_sp")
t.mud_maxsp = GetEntity ("mud_maxsp")
t.mud_ep = GetEntity ("mud_ep")
t.mud_maxep = GetEntity ("mud_maxep")
t.mud_monster_name = GetEntity ("mud_monster_name")
t.mud_monster_health = GetEntity ("mud_monster_health")
t.mud_max_mon_health = GetEntity ("mud_max_mon_health")

-- see if changed
local changed = false
for k, v in t do
  if old_t [k] ~= t [k] then
    changed = true
  end -- if
end

-- exit if nothing changed
if not changed then
  return
end -- if

-- function to send UDP packets with magic keyword and port number
local function udp (msg)
  UdpSend ("127.0.0.1", 4111, "magic," .. msg)
end  -- function udp

-- function to calculate percent, with guard against divide by zero
local function percent (amount, max)
  amount = tonumber (amount)
  max = tonumber (max)

  if not (amount and max) then
    return 0
  end -- if no values supplied

  if max &lt;= 0 then
    return 0
  end -- if too low

  if amount &gt; max then
    return 100
  end -- if too high

  return math.floor (amount / max * 100)
end -- function percent 

-- title, colours, bar sizes, labels
udp ("title,Status")
udp ("textcolour,0")
udp ("backcolour,14804223")
udp ("config,10,5,100,15,70,320,20")
udp ("labels,HP,SP,EP,Monster")

-- bar "foreground" colours
udp ("colours," .. 
        ColourNameToRGB ("darkgreen") .. "," .. 
        ColourNameToRGB ("darkblue") .. "," .. 
        ColourNameToRGB ("saddlebrown") .. "," .. 
        ColourNameToRGB ("dimgray"))

-- bar "background" colours
udp ("fillcolours," .. 
        ColourNameToRGB ("lightgreen") .. "," .. 
        ColourNameToRGB ("lightblue") .. "," .. 
        ColourNameToRGB ("tan") .. "," .. 
        ColourNameToRGB ("gainsboro"))

-- percentages
udp ("values," ..
     percent (t.mud_hp, t.mud_maxhp) .. "," ..
     percent (t.mud_sp, t.mud_maxsp) .. "," ..
     percent (t.mud_ep, t.mud_maxep) .. "," ..
     percent (t.mud_monster_health, t.mud_max_mon_health)
    )

-- monster name
udp ("text,5,95," .. t.mud_monster_name)

end -- do</send>

  </timer>
</timers>



What this does is, every 5 seconds, check the entity values, and if they have changed, send an update to the status window. You need to download the status bar window as mentioned above and start it up (ie. execute the .exe) manually.

What you should see 5 seconds later is the status bar with the 4 bars drawn, and then as the updates arrive from the MUD the length of the bars will update. You can see the names of the colours for each bar in the timer above, you can customise that to your choice.

Just drag the window around to a convenient location on the screen.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #25 on Fri 17 Dec 2004 01:01 AM (UTC)
Message
So can you use this to capture channel conversations?

Also, will it scroll if too many lines show up?

Additionally, How would I use it for an external statusbar for my prompt? Considering I know what % life and what not I'm at. I don't need to calculate it out.
Top

Posted by Nick Gammon   Australia  (23,072 posts)  Bio   Forum Administrator
Date Reply #26 on Fri 17 Dec 2004 01:21 AM (UTC)
Message
No, this particular implementation is not scrolling. I was trying to keep it simple, and do a bar graph.

To capture a conversation, just use "send to notepad".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #27 on Fri 17 Dec 2004 03:06 AM (UTC)
Message
How complicated would it be to make this bar scrolling?
Top

Posted by Nick Gammon   Australia  (23,072 posts)  Bio   Forum Administrator
Date Reply #28 on Fri 17 Dec 2004 04:30 AM (UTC)
Message
Why do you want a scrolling bar? It would be a different sort of window, a text window with scrollbars.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Afkeraeon   (7 posts)  Bio
Date Reply #29 on Fri 17 Dec 2004 06:31 PM (UTC)
Message
Thanks _ALOT_ for the help with the statusbar Nick!
Though I seem to have a rather odd problem now. After an hour or two the statusbars disappear leaving a white window with only the labels left. I downloaded ShellEnhanced to make the Statusbar always on top, other than that I have no clue about what might be messing with it :/
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.


167,967 views.

This is page 2, subject is 4 pages long:  [Previous page]  1  2 3  4  [Next page]

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.