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

Gammon Software Solutions 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?
(New message)
Subject: InfoBox module to do gauges etc.
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  3  

Posted by Eupher   (6 posts)  [Biography] bio
Date Sat 14 Aug 2010 03:37 AM (UTC)  quote  ]
Message
Thanks a ton for this module. It looks great.

I'm very new to all of this and am trying to do something that may already be easy, or possibly could require changing the module...

Basically, I want a MW that has a dynamic set of Bars... one for the hp's of each current member of my group. Whenever I check group status, I'd like to update the respective hp bar of each member, assuming it's not a new member. In that case I'd need to add a hp bar for them ( and delete the bar of any group members that left the group).

The approach that I thought of was to have the bars indexed by group member name... so I could do a test like:

if ( MW ["Bars"] [member.name] ) then
-- update their bar
else
-- add their bar and set its initial values
end

Is there a way to do something like this cleanly? Am I being stupid again and overlooking something obvious? :) I'd hate to have to loop through all the bars checking the captions for the names...

Thanks!
[Go to top] top

Posted by Nick Gammon   Australia  (19,183 posts)  [Biography] bio   Forum Administrator
Date Mon 19 Jul 2010 08:38 PM (UTC)  quote  ]
Message
OK did that.

- Nick Gammon

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

Posted by WillFa   USA  (517 posts)  [Biography] bio
Date Mon 19 Jul 2010 05:26 PM (UTC)  quote  ]
Message
Nick, can you edit the first post to clarify that Infobox is now in the base install and not required to download from the plugins section?

Someone searching for gauges and how to's might get a little confused.
[Go to top] top

Posted by Nick Gammon   Australia  (19,183 posts)  [Biography] bio   Forum Administrator
Date Fri 02 Jul 2010 05:49 AM (UTC)  quote  ]
Message
The health bar plugin below shows most of what is required:

Template:post=9270 Please see the forum thread: http://gammon.com.au/forum/?id=9270.


You basically just need to modify the trigger to match what you receive. You don't have to have the screen fill up with prompts if you don't want, because you could omit them from output.

- Nick Gammon

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

Posted by Thorr686   (4 posts)  [Biography] bio
Date Thu 01 Jul 2010 11:48 PM (UTC)  quote  ]
Message
Ok, well I know that the mud i play on does not have the ability to update the health bars without the prompt appearing so unfortunately i will just have to have a bunch of spam on my screen.

I will look through those pages and get back to you with my progress.

A general process of what I will need, sorta like a toolbox with all my tools in it before i start building my plugin would still be helpful. Thanks for the quick response :)

Thorr
[Go to top] top

Posted by KaVir   Germany  (117 posts)  [Biography] bio
Date Thu 01 Jul 2010 01:32 PM (UTC)  quote  ]
Message
Thorr686 said:
I am familiar with C++ coding but have never done any LUA stuff. Any help would be appreciated.

I was in the same position as you about 2.5 months ago - familiar with C++, but no experience with Lua or MUSHclient scripts. I wanted to create a plugin with energy bars, but wasn't really sure where to start.

What I did in the end was to download Nick's Experience_Bar plugin from here: http://www.gammon.com.au/mushclient/plugins/

Then I spent some time playing with it and reading the documentation on this site. I googled Lua to find the syntax for certain things when necessary, but the language is pretty simple and you can pick most of it up as you go along.

After a couple of weeks I'd modified the plugin into what I wanted, and felt confident enough to start working on my own plugin. Two months later and I've now got energy bars, a background image, an avatar, timers, a couple of click-to-move maps, and information about your opponent.

A couple of days ago I posted a thread on MudBytes where I briefly discussed the different stages of my plugin, with a screenshot at each stage. Perhaps you'll find it of interest: http://www.mudbytes.net/index.php?a=topic&t=2899

So my suggestion would be to look through the existing plugins, read over the documentation, and have a play - try changing things, see what works and what doesn't, get a feel for it.

One other point worth mentioning though: I don't know which mud you play, but if it supports an out-of-band protocol such as ZMP, ATCP/2, MSDP or 102, you can have energy bars that don't rely on your prompt. Not only does this make the plugin easier to write, it's also nicer to use, as you don't have to keep hitting enter for the energy bars to update.
[Go to top] top

Posted by Thorr686   (4 posts)  [Biography] bio
Date Thu 01 Jul 2010 10:13 AM (UTC)  quote  ]
Message
I am completely new to LUA and to Writing my own Plugins/Scripts. I am trying to write a plugin for a miniwindow for my HP/EP (health and energy points)

Could you guys make a guide, like step by step as to what is requried to make this? I know that guys mention a prompt/hp trigger that is required, can anyone go into some detail, with the steps required, IE what variables need to be stored and then called up in the plugin?

I am familiar with C++ coding but have never done any LUA stuff. Any help would be appreciated.

Also, my prompt looks like this

HP:190/190 EP:190/190

thanks guys
[Go to top] top

Posted by Twisol   USA  (2,230 posts)  [Biography] bio
Date Thu 04 Feb 2010 11:21 PM (UTC)  quote  ]
Message
I have to agree, the HSL-based gradients look brilliant.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (19,183 posts)  [Biography] bio   Forum Administrator
Date Thu 04 Feb 2010 11:19 PM (UTC)  quote  ]
Message
That looks nice, I'll add the colors.lua file to the next release of MUSHclient.

My test which used the module rather than copying bits of it in, was:


require "colors"

local width = 800
WindowCreate("test",                            -- miniwindow name
  0, 0,                                          -- left, top (ignore)
  width, 350,                                    -- width, height
  12,                                            -- position (centre all)
  8,                                             -- flags (ignore mouse)
  ColourNameToRGB("black"))                      -- background colour
WindowShow("test", true)                        -- show miniwindow
WindowGradient("test",                          -- miniwindow name
  0, 0, width-1, 100-1,                          -- left, top, right, bottom
  ColourNameToRGB("lime"),                       -- start colour (0x00FF00)
  ColourNameToRGB("red"),                        -- end   colour (0x0000FF)
  1)                                             -- mode (horizontal)
for n = 0, width-1 do
  local r, g, rgb
  r = math.floor(255*n/(width-1))
  g = math.floor(255*(width-1-n)/(width-1))
  rgb = r*16^0+g*16^2                           -- rgb colour space
  WindowLine("test",                            -- miniwindow name
    n, 125, n, 225-1,                            -- left, top, right, bottom
    rgb, 0, 1)                                   -- pen colour, pen style (solid), pen width
  r, g, b = colors.hsl_to_rgb(120-120*n/(width-1), 1, 0.5) -- hsl colour space
  rgb = math.floor(255*r)*16^0+
         math.floor(255*g)*16^2+
         math.floor(255*b)*16^4

  WindowLine("test",                            -- miniwindow name
    n, 250, n, 350-1,                            -- left, top, right, bottom
    rgb, 0, 1)                                   -- pen colour, pen style (solid), pen width
end
Redraw()

- Nick Gammon

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

Posted by Morat   (18 posts)  [Biography] bio
Date Thu 04 Feb 2010 09:19 PM (UTC)  quote  ]

Amended on Thu 04 Feb 2010 09:33 PM (UTC) by Morat

Message
Great job, WillFa!

I think using HSL color space gives a more pleasing gradient then RGB color space.

HSL Color Theory Computation in Lua
http://sputnik.freewisdom.org/lib/colors/

Example Image (top gradient uses RGB & bottom gradient uses HSL)
http://i38.tinypic.com/29o0q4k.jpg

The following Lua script shows three power gauges using WindowGradient, WindowLine with RGB values and WindowLine with HSL values.

local function hsl_to_rgb(h, s, L)              -- h = Hue
  local h = h/360                               -- s = Saturation
  local m1, m2                                  -- L = Lightness
  if L<=0.5 then
    m2 = L*(s+1)                                -- hsl_to_rgb(120, 1, 0.5) = 0x00FF00
  else                                          -- hsl_to_rgb(  0, 1, 0.5) = 0x0000FF
    m2 = L+s-L*s
  end                                           -- ColourNameToRGB("lime") = 0x00FF00
  m1 = L*2-m2                                   -- ColourNameToRGB("red")  = 0x0000FF
  local function _h2rgb(m1, m2, h)
    if h<0 then h = h+1 end
    if h>1 then h = h-1 end
    if h*6<1 then
      return m1+(m2-m1)*h*6
    elseif h*2<1 then 
      return m2 
    elseif h*3<2 then 
      return m1+(m2-m1)*(2/3-h)*6
    else
      return m1
    end
  end
  return math.floor(255*_h2rgb(m1, m2, h+1/3))*16^0+
         math.floor(255*_h2rgb(m1, m2, h    ))*16^2+
         math.floor(255*_h2rgb(m1, m2, h-1/3))*16^4
end
local width = 800
WindowCreate("test",                            -- miniwindow name
  0, 0,                                          -- left, top (ignore)
  width, 350,                                    -- width, height
  12,                                            -- position (centre all)
  8,                                             -- flags (ignore mouse)
  ColourNameToRGB("black"))                      -- background colour
WindowShow("test", true)                        -- show miniwindow
WindowGradient("test",                          -- miniwindow name
  0, 0, width-1, 100-1,                          -- left, top, right, bottom
  ColourNameToRGB("lime"),                       -- start colour (0x00FF00)
  ColourNameToRGB("red"),                        -- end   colour (0x0000FF)
  1)                                             -- mode (horizontal)
for n = 0, width-1 do
  local r, g, rgb
  r = math.floor(255*n/(width-1))
  g = math.floor(255*(width-1-n)/(width-1))
  rgb = r*16^0+g*16^2                           -- rgb colour space
  WindowLine("test",                            -- miniwindow name
    n, 125, n, 225-1,                            -- left, top, right, bottom
    rgb, 0, 1)                                   -- pen colour, pen style (solid), pen width
  rgb = hsl_to_rgb(120-120*n/(width-1), 1, 0.5) -- hsl colour space
  WindowLine("test",                            -- miniwindow name
    n, 250, n, 350-1,                            -- left, top, right, bottom
    rgb, 0, 1)                                   -- pen colour, pen style (solid), pen width
end
Redraw()
[Go to top] top

Posted by Nick Gammon   Australia  (19,183 posts)  [Biography] bio   Forum Administrator
Date Fri 08 Jan 2010 09:45 PM (UTC)  quote  ]
Message
Willfa, is this module at release status? I might add it into the next distribution of MUSHclient, to encourage its use in general plugin development.

- Nick Gammon

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

Posted by WillFa   USA  (517 posts)  [Biography] bio
Date Fri 21 Aug 2009 03:06 AM (UTC)  quote  ]
Message
Sorry, I wrote all the documentation right in the Lua module. What I normally do is have another world open, that has it's IP Adress set to 0.0.0.0, a scripting prefix set, and auto-say turned on that's set to prefix each line with the scripting char and checked to send to the interpreter. I have this world saved as Scratchpad.

When I want a quick Lua interactive session, the dummy world serves nicely.

[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Fri 21 Aug 2009 02:03 AM (UTC)  quote  ]
Message
Ok I don't think I understood the demo properly I'll go back and read some more.
I don't suppose you have the documentation in another format. Just a text file would
be great so I can have it up while I'm working with the module.

Thanks WillFa, this module is great btw, I'm itching to make a slick looking health
bar etc plugin for Aardwolf.
[Go to top] top

Posted by WillFa   USA  (517 posts)  [Biography] bio
Date Fri 21 Aug 2009 12:53 AM (UTC)  quote  ]

Amended on Fri 21 Aug 2009 01:02 AM (UTC) by WillFa

Message
I wrote this before movewindow, and I haven't gone through it's code to know exactly how it works... I'll have to look into it later this weekend.

Adding text and hotspots are simple tho. "To simplify the process" </marketing spin> or perhaps as a limitation depending on your perspective, each cell can easily be a hotspot (but not divided up into smaller sections) by setting a table with the parameters the WindowHotSpot function.


require "InfoBox"
InfoBox:Doc("button")


for more information.

Also, go through the Demo plugin for a get ready quick run-through of what InfoBox does.


Digging into the module might be ... fun. :) It's 73k of code and documentation. ;) It's mostly well-written though, so looking at the source shouldn't be mind-boggling... just overwhelming at first.

Except for, obviously, mcicon.png; all these are screen shots of InfoBox Windows.
http://cid-73890baf188d56e7.skydrive.live.com/browse.aspx/MCForum
Doing text is fairly simple with them, as you can see with InfoBox1.2.jpg .


[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Thu 20 Aug 2009 11:11 PM (UTC)  quote  ]
Message
How would I go about using movewindow.lua with this?

Is it possible to make simple changes like adding a hotspot or some text with out digging into the module?
[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.


22,792 views.

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

[New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]