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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  InfoBox module to do gauges etc.
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

InfoBox module to do gauges etc.

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


Pages: 1 2  3  

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Wed 03 Dec 2008 07:24 PM (UTC)

Amended on Mon 19 Jul 2010 08:38 PM (UTC) by Nick Gammon

Message
Willfa has written an extensive Lua module which lets you easily set up gauges and other information in MUSHclient, using the new Miniwindows. Sample screenshots are in the next posting in this thread.

The module is in this file:

http://www.gammon.com.au/mushclient/plugins/InfoBox.zip

[EDIT] The file InfoBox.lua is now part of the MUSHclient install (from version 4.47 onwards) so you don't need to download anything extra in order to use it.


This file includes:


  • InfoBox.lua (put into your MUSHclient "lua" subdirectory)
  • InfoBox_Demo.xml (demo plugin - put into your world/plugins directory)


The demo plugin is best run in a dummy world (just make a new world with IP address of 0.0.0.0 and then install the plugin). It runs you through the various things the module can do.

As described in the demo:


For a Quick start, you can be up and running with only the following lines of code:

require "InfoBox"
box = InfoBox:New("HP")
hp = box:AddBar("HP: ", 50)


and in your prompt/hpbar trigger:

hp.value = <new percentage number>
box:Update()


(Results in next posting).

This is a great contribution, as it takes all the technical stuff needed to make miniwindows appear, and leaves you with nice pleasing results. Applications could be for HP/Mana gauges, stats (str/int/dex etc.), combat progress, and other things.

Thanks to Willfa for making it available.


- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 03 Dec 2008 07:24 PM (UTC)
Message


- Nick Gammon

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

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #2 on Wed 03 Dec 2008 07:58 PM (UTC)
Message
The Demo plugin is written as a demo or tutorial and has samples, as you can see above.

The module itself has a Doc() function that's more of an object reference but still serves as on-line help.

Most values or functions should be intuitively named, and easily viewed by tprint'ing either the module, or the table returned from the New() function (referred to as MiniWindow or MW in my documentation).


Thanks again Nick, this module started out as your hpbar sample, and also borrows from your color coding and commas functions. Without your samples, this never would have evolved. Without your application, this wouldn't have come into existence either... ;)


[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Reply #3 on Fri 12 Dec 2008 06:24 PM (UTC)
Message
I've just started using this InfoBox module, and it's pretty great so far! I have a couple of questions and/or feature requests, if I may.

1. I'm interested in creating more than one panel docked to the same part of the screen, such that I have one group of bars (just a pair of text labels, really) for something like date/time that sits above another group of bars for health, mana, and ego, both in the SE corner of my screen. Basically, I want to dynamically build a stack of miniwindows from the corner that goes up the side. Would it be possible to nest these and have info boxes inside other info boxes?

2. Any chance that this module will support hotspots? Or is that left as an exercise for the end user to explore? :)

3. Why is it that when I set the .backgroundColour for an info box that I have to reverse the hex for red with the hex for green? For example, I had to use 0xff901e instead of 0x1e90ff to get "dodgerblue" color.

4. I had troubles blending my gauges (in "glass" + "gradientFixed" mode) from certain colors to certain other colors. They looked normal at 100%, but they went part black and part some odd gradient when the percentage fell to less than 100. Just played around with it until I found "compatible" colors...

Thanks for making all this available, guys! Great work.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Fri 12 Dec 2008 09:03 PM (UTC)
Message
Quote:

Why is it that when I set the .backgroundColour for an info box that I have to reverse the hex for red with the hex for green?


The order of RGB in a hex constant is confusing, probably because of the endian-ness issue of CPUs.

If you look up Red in the Colour Picker, you will see:


MXP: #FF0000
JScript: 0x0000FF


Note that when using HTML (or MXP) the byte order is:

#RRGGBB

However when expressing as a simple number (eg. in hex) it is:

0xBBGGRR

As you can also see from the colour picker red is in the lower-order byte. Now when using Little Endian (as Intel does), when expressed in memory, that number will be:

RR GG BB

So it actually makes sense when stored in memory itself (little endian puts the little byte first). For more information on endian, see:

http://en.wikipedia.org/wiki/Endian



- Nick Gammon

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

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #5 on Fri 12 Dec 2008 10:12 PM (UTC)
Message
Thanks Larkin, the feedback means a lot to me. :)

I'll answer out of order, if that's okay.

3. Nick's answer was precise, and dead on; there's nothing I could add.

4. The glass effect works by blending a gray gradient image over the luminance channel of the bar, some colors that have their luminance at 100% won't really glass well, and all colors tend to end up lighter than what you specify. That's why the samples use colour_names.firebrick instead of colour_names.red.

As for the weird black/gray issue, there may be a bug in my math that I didn't find. If you can give me example colors I'll look into it.

2. Just put hotspots in two days ago myself. With 3 other small changes so far (backgroundColour value applying to individual bars as well as the whole window, so effects like Nick's Aardwolf inventory titlebars are possible; top and left (thinking of renaming them to cellTop and cellLeft) getting set during the draw routine so the absolute coordinates of where a bar is drawn are available if you did want to add/draw after the Infobox is updated) I'll probably beat on it over the weekend before harassing Nick with an update.

(see http://cid-73890baf188d56e7.skydrive.live.com/self.aspx/MCForum/Infobox1.2.jpg )

1. The module itself will draw as many bars as you throw at it. I suppose the only limitation would be a consistent number of columns. Different section groupings could be achieved by tinkering with a Bar's .padding value to add some extra separation between them.
i.e.

date , now = "DEC 12" , "6:00 PM"
MW = InfoBox:New("Test")
MW:AddBar( string.format("%-22s%20s", date, now) )
MW.Bars[1].padding = 15
MW.Bars[1].barStyle = 0
MW:AddBar("HP", 100)
MW:AddBar("Mana", 80)
MW:AddBar("Ego", 60)
MW.Bars[#MW.Bars].padding = 15
MW:AddBar("TNL", 86)
--etc


What would you like for these different InfoBoxes?
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Reply #6 on Sat 13 Dec 2008 02:48 AM (UTC)
Message
As an example, if I use glass + gradientFixed with orange (good) and gray (bad), I get the bad blending.

I'm going to play around with the padding, width, row/column to see if I can make a layout I like. Thanks for the help with that.

Looking forward to the next release already!
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #7 on Sat 13 Dec 2008 04:08 AM (UTC)
Message
Thanks Larkin!

That bug was a couple of misplaced parens. If you're anxious to have it working in the interim, change line 987 to read:


        Cs[i+1] = tonumber(string.format("%02x%02x%02x",  math.floor(b1 - (step.b * i) ) % 256 , math.floor(g1 - (step.g * i) ) % 256 , math.floor(r1 - (step.r * i) ) % 256 ),16)



BTW, If you're used to using hexcodes for colors, all the colour functions take "#RRGGBB" strings.

i.e. "#FF0000" == 0x0000FF == "red" == colour_names.red
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Reply #8 on Sat 13 Dec 2008 11:34 AM (UTC)
Message
It was line 956 in the version I have here. Thanks for the fix!
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #9 on Tue 16 Dec 2008 07:17 PM (UTC)
Message
Version 1.2 has been sent off to Nick to update the web server. Hopefully it will be available shortly.

Check the Revisions.txt file in the zip to see what's new.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Wed 17 Dec 2008 05:18 AM (UTC)
Message
Version 1.2 is now available here:

http://www.gammon.com.au/mushclient/plugins/InfoBox_v1.2.zip

- Nick Gammon

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

Posted by Itzie   Australia  (16 posts)  [Biography] bio
Date Reply #11 on Mon 16 Feb 2009 03:12 PM (UTC)
Message
How would someone go about making a plugin for things with that? I would like to make bars for Hp, mana, moves, tnl, alignment and anything else I can think of :P

Would someone please be able to give me an example? I'm not sure where to start...
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #12 on Mon 16 Feb 2009 04:31 PM (UTC)
Message
Download the zip, there's an Infoboxdemo.xml plugin that serves as a tutorial and sample code.
[Go to top] top

Posted by Itzie   Australia  (16 posts)  [Biography] bio
Date Reply #13 on Mon 16 Feb 2009 11:43 PM (UTC)
Message
I did, though I am not sure how to get started with it.
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #14 on Tue 17 Feb 2009 01:07 AM (UTC)
Message
Copy Infobox.lua to the C:\Program Files\Mushclient\Lua directory.

Press CTRL+N to make a new world.
Type 0.0.0.0 in the world's IP address field.
Click OK.
Press CTRL+SHIFT+P to bring up the Add Plugins dialog.
Click Add
Browse to where you extracted the InfoBox_Demo.xml
Click OK
Click OK


The module doesn't teach you how to make a prompt/hpbar trigger, or how to code in lua in general, tho a lot of the sample code can show you where to start.

[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.


39,496 views.

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

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 FutureQuest]