[Home] [Downloads] [Search] [Help/forum]


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.
[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  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] Refresh page


Pages: 1  2  3  4 

Posted by Luowei98   China  (7 posts)  [Biography] bio
Date Reply #45 on Thu 04 Oct 2007 12:49 AM (UTC)
Message
yes, i want to auto load state bar window at my plugin. i use os.execute("StatusBar.exe") to do it, and it open a dos window to open state bar window, state bar does not work until i close dos window. i don't know why, and how can i do it automatically.
the second question is path of os.execute use, i have to put the file StatusBar.exe at mc directory, if not do this, status bar window can not open.
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #46 on Thu 04 Oct 2007 05:59 AM (UTC)

Amended on Thu 04 Oct 2007 07:20 AM (UTC) by Nick Gammon

Message
This should start it up from the MUSHclient executable directory, and not keep a DOS window open:


os.execute ("start " .. GetInfo (66) .. "\\" .. "statusbar.exe")


To do it automatically put that inside a function called OnPluginInstall inside a plugin. Eg. in Lua:


function OnPluginInstall ()
  os.execute ("start " .. GetInfo (66) .. "\\" .. "statusbar.exe")
end -- function OnPluginInstall 

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Luowei98   China  (7 posts)  [Biography] bio
Date Reply #47 on Fri 05 Oct 2007 01:58 AM (UTC)
Message
thank nick for your answer.
my MUSHclient executable directory is "C:\Program Files\MUSHclient\", so when i use start command, it does not work. and i changed it like
os.execute ("start \"\" \"" .. GetInfo (66) .. "\statusbar.exe\"")
it is OK.
it works well now, thank you!
[Go to top] top

Posted by Luowei98   China  (7 posts)  [Biography] bio
Date Reply #48 on Fri 05 Oct 2007 09:23 AM (UTC)
Message
i have new problem now, when i load status bar window at the function called OnPluginInstall, the MUSHclient lost focus, current window change to status bar window. i want to reactive MUSHclient automatically, how can i do it?
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #49 on Fri 05 Oct 2007 08:56 PM (UTC)
Message
http://www.gammon.com.au/scripts/doc.php?function=ActivateClient

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Luowei98   China  (7 posts)  [Biography] bio
Date Reply #50 on Sun 07 Oct 2007 05:19 AM (UTC)
Message
great! it work very well. thanks alot!
[Go to top] top

Posted by Luowei98   China  (7 posts)  [Biography] bio
Date Reply #51 on Sat 13 Oct 2007 12:03 PM (UTC)
Message
hi nick, i have a new problem now, that is when the MCL file which have load status bar window can not be save.
it always say "access to XXX.MCL was denied".
what is this mean, and how can i solve it?

and more question is, how can i close the status bar window when i close one session of the MUSHclient?
i think to use send a close message to status bar window, and status bar window close itself, but i am not a programmer, and can not modifie the C file of status bar window. can u help me?

thanks a lot!
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #52 on Sat 13 Oct 2007 11:57 PM (UTC)
Message
If you edit the statusbar.cpp file that came with the download, it explains what each of the commands are, in comments near the top. You want the "quit" command.

I don't know why it won't save, try saving under a different name and then quitting MUSHclient or rebooting the PC.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Luowei98   China  (7 posts)  [Biography] bio
Date Reply #53 on Sun 14 Oct 2007 01:35 AM (UTC)
Message
oh, yeah! it have "quit" command. thanks!
[Go to top] top

Posted by Vicissitude   (1 post)  [Biography] bio
Date Reply #54 on Fri 06 Jun 2008 02:42 PM (UTC)
Message
I'm not sure how the status bar is set up. I've dl'ed the statusbar.zip file and unzipped it. The link to the additional Lua files providing socket support in Nick's original post did not work, so I did a google search and found the latest file here:
http://luaforge.net/frs/?group_id=23&release_id=837
Where do I put the .lua files from luasocket-2.0.2-lua-5.1.2-Win32-vc6.zip? The zip file has subfolders which complicates things. The instructions given by the programmer are here: http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/installation.html

I would greatly appreciate it if someone looked into this for me.
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #55 on Fri 06 Jun 2008 09:19 PM (UTC)
Message


I got it working like this:


  • As mentioned on the MUSHclient downloads page:

    http://www.gammon.com.au/downloads/dlmushclient.htm

    Download the file with the custom status bar program in it, namely:

    http://www.gammon.com.au/files/utils/statusbar.zip

  • Download the amended LuaSocket stuff as described here, about halfway down the page:

    http://www.gammon.com.au/forum/?id=8319

    Specifically you want the file:

    http://www.gammon.com.au/files/mushclient/lua5.1_extras/luasocket-2.0.1.zip

    Unzip that into the same directory as MUSHclient.exe (eg. c:\Program Files\MUSHclient if that is where you put it).

  • Manually start up StatusBar.exe (for now) by double-clicking it, and accepting it as a valid program if your firewall complains that it is trying to access the Internet (that is because it opens a "listening" UDP port).

    You should see a blank (white) status bar window.

  • In MUSHclient's File -> Global Preferences -> Lua, make sure "Allow DLLs to be loaded" is checked (as luasocket is a DLL). Make sure your current world is trusted (in the script on that page), or make the first line:

    
    trust_all_worlds = true
    


    If you had to change it, go to the Game menu -> Reload Script File.

  • Copy and paste the example from page 1 of this thread, minus the 'dofile "lua.lua"' part, as follows, into an Immediate window (Ctrl+I):

    
    
    socket = require "socket"
    s = socket.udp ()
    s:setpeername ("127.0.0.1", 4111)
    
    s:send ("magic,title,Status Bar - BabbleMUD")
    s:send ("magic,config,10,5,100,15,60,320,20")
    s:send ("magic,size,10,10,350,140")
    s:send ("magic,textcolour," .. ColourNameToRGB ("indigo"))
    s:send ("magic,backcolour," .. ColourNameToRGB ("lightsteelblue"))
    s:send ("magic,labels,HP,Mana,Move,XP")
    s:send ("magic,values,10,20,30,80")
    s:send ("magic,font,Comic Sans MS,10,0,700")
    s:send ("magic,colours," .. 
            ColourNameToRGB ("darkgreen") .. "," .. 
            ColourNameToRGB ("darkblue") .. "," .. 
            ColourNameToRGB ("saddlebrown") .. "," .. 
            ColourNameToRGB ("dimgray"))
    s:send ("magic,fillcolours," .. 
            ColourNameToRGB ("lightgreen") .. "," .. 
            ColourNameToRGB ("lightblue") .. "," .. 
            ColourNameToRGB ("tan") .. "," .. 
            ColourNameToRGB ("gainsboro"))
    
    s:send ("magic,text,5,88,Darkhaven Square")
    
    s:close ()
    


  • Your status bar should now look like the screen dump on page 1 of this thread.



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #56 on Fri 06 Jun 2008 09:21 PM (UTC)

Amended on Fri 06 Jun 2008 09:23 PM (UTC) by Nick Gammon

Message
However an important point is that you don't need Luasocket to make it work - that was for the example, and is one way of going about it. In this example (also from page 1):


function multiline_trigger (name, line, wildcards)

  local function udp (msg)
    UdpSend ("127.0.0.1", 4111, "magic," .. msg)
  end  

  udp ("title,Inventory")
  udp ("size,10,10,300,300")
  udp ("config,10,5,100,15,80,300,20")
  udp ("font,Harem,12")
  udp ("textcolour,0")
  udp ("backcolour,14804223")
  udp ("text,5,5," .. wildcards.inventory)

end -- function


That simply uses UdpSend which is built into MUSHclient. If you do a trigger like that, you can skip all the steps about installing Luasocket, letting MUSHclient read DLLs, and so on.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #57 on Fri 06 Jun 2008 10:13 PM (UTC)

Amended on Fri 06 Jun 2008 10:42 PM (UTC) by Nick Gammon

Message
I got a couple of triggers to work nicely, it was a bit trickier than I thought, as I haven't looked at it for a while, and things have changed a bit.


<triggers>
  <trigger
   enabled="y"
   match="&lt;*/* hp */* m */* mv */* xp&gt;*"
   name="status_prompt"
   send_to="12"
   sequence="100"
  >
  <send>

-- calculate percentages, put them in a table 
status_table = {
   %1/%2 * 100,  -- hp
   %3/%4 * 100,  -- mana
   %5/%6 * 100,  -- movement
   %7/%8 * 100,  -- xp
     }

if not status_window_open then
  status_window_open = true
  
  udp = function (msg)
    UdpSend ("127.0.0.1", 4111, "magic," .. msg)
  end  

  os.execute ('start "statusbar" "' .. GetInfo (66) .. 'StatusBar.exe"')

  -- it might take a second to start up StatusBar.exe, so do this a second later
  DoAfterSpecial (1, [[
    udp ("title,Status Bar - SMAUG")
    udp ("config,10,5,100,15,60,320,20")
    udp ("size,10,10,350,140")
    udp ("textcolour," .. ColourNameToRGB ("indigo"))
    udp ("backcolour," .. ColourNameToRGB ("lightsteelblue"))
    udp ("labels,HP,Mana,Move,XP")
    udp ("font,Comic Sans MS,10,0,700")
    udp ("colours," .. 
            ColourNameToRGB ("darkgreen") .. "," .. 
            ColourNameToRGB ("darkblue") .. "," .. 
            ColourNameToRGB ("saddlebrown") .. "," .. 
            ColourNameToRGB ("dimgray"))
    udp ("fillcolours," .. 
            ColourNameToRGB ("lightgreen") .. "," .. 
            ColourNameToRGB ("lightblue") .. "," .. 
            ColourNameToRGB ("tan") .. "," .. 
            ColourNameToRGB ("gainsboro"))
    udp ("values," .. table.concat (status_table or {}, ","))
    ActivateClient ()  -- get focus back
  ]], 12)
else
  udp ("values," .. table.concat (status_table, ","))
end -- first time
</send>
  </trigger>

  <trigger
   enabled="y"
   keep_evaluating="y"
   match="Exits: *"
   send_to="12"
   sequence="100"
  >
  <send>

if udp then
  udp ("text,5,88,%0")
end -- status window available

</send>
  </trigger>
</triggers>




To make this work, first I set my SMAUG prompt to show all the stuff it needs:


prompt <%h/%H hp %m/%M m %v/%V mv %x/%X xp> 


That is, current and max HP, current and max Mana, current and max movement points, xp and XP to go. This lets me calculate percentages for the status bar.

Then after installing the statusbar.exe from:

http://www.gammon.com.au/files/utils/statusbar.zip

It was ready to work. What the first trigger does is calculate the percentages, and then the first time around, it uses os.execute to start up the statusbar.exe program. (You need to make the world "trusted" for this to work). It then uses DoAfterSpecial to configure the status window a second later. The reason for this is to give the status bar program time to start.

From then on, each prompt updates the status bar.

The second trigger updates the current exits.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #58 on Fri 06 Jun 2008 10:16 PM (UTC)
Message

This is what it looked like:


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #59 on Fri 06 Jun 2008 11:07 PM (UTC)
Message
A nice trick is to make the status bar window auto-position itself adajacent to the world window where it is being used. To do this replace the line above:


udp ("size,10,10,350,140")


... by this:


    -- where is the world window?
    local mc_location = GetWorldWindowPosition (1, 1)
    local width = 350
    local height = 140
    local t = {
      mc_location.left - width - 10,
      mc_location.top - 30,
      width,
      height,
      }
    udp ("size," .. table.concat (t, ","))


What this does is use GetWorldWindowPosition to find the position of the world window, in global screen co-ordinates. We then subtract the width of the status window (350 in this case) from the left of the MUSHclient window, which puts it exactly to the left of it. I added a "fudge" factor of 10, to allow room for the window edge.

Then it takes the top of the MUSHclient window, and subtracts 30 to allow for the width of the title bar, so both title bars line up.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


161,098 views.

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

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]