[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]  Cyote's InfoBox question
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Cyote's InfoBox question

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


Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Sat 29 Nov 2014 12:48 PM (UTC)

Amended on Sat 29 Nov 2014 12:49 PM (UTC) by WillFa

Message
Better late than never, right?

First, a small bug fix was made to InfoBox.lua.
Line 490: z= tonumber(z) or z
I'll send the updated file to Nick to make his life easier.

Since InfoBox draws Bars vertically down column 1, then Column 2, etc... You'll need to get a little creative in how you add more Bars. There's an InsertBar function that handles the reordering for you, if you can figure out what index you want to put them in...

InfoBox will just watch the GroupList table, which I figure will be kept updated by your triggers. There's litle need to mess with the Addgroupmembers function once you set the styles how you want. You can mess with the UpdateLabels() function to do other Happy stuff as you get more familiar and ambitious.


require "InfoBox"

HPFormat = "@k  HP: %i/%i"
ManaFormat = "@kMana: %i/%i"
MoveFormat = "@kMove: %i/%i"

function grcall()
  WinWith = 900
  
  GW = {}
  GW = InfoBox:New("Title")
  GW.windowWidth = WinWith
  GW:WindowPosition(GW.windowPositions.NE)
  GW.columns = 7

  GW.axis = "rows"
  
  
  GW:AddBar("Name")
  GW:AddBar("Status")
  GW:AddBar("HP")
  GW:AddBar("Mana")
  GW:AddBar("Move")
  GW:AddBar("TNL")
  GW:AddBar("Align")
  
  Addgroupmates()

  UpdateLabels()
 
end -- function 


function Addgroupmates()
  
  for k,Member in ipairs(GroupList) do 
    GW:InsertBar(k + 1 , Member.Name, 0, 0, 0, false, 0)
    GW:InsertBar(2*k+2, Member.Status, 0, 0, 0, false, 0)

    a = GW:InsertBar(3*k+3,  "", Member.perHP, "green", "firebrick", false, GW.barStyles.gradientFixed + GW.barStyles.glass )
    a.gaugeHeight = a.cellHeight * .3
    a:WatchCaption  ( "GroupList["..k.."].formattedCap")
    a:WatchValue ("GroupList[" .. k .. "].perHP")
    
    b = GW:InsertBar(4*k+4,"", 0 , "dodgerblue", "purple", false, GW.barStyles.gradientFixed + GW.barStyles.glass)
    b:WatchCaption  ("GroupList["..k.."].formattedMana")
    b:WatchValue  ("GroupList["..k.."].perMana")
    b.threshold = 50
    b.gaugeHeight = b.cellHeight * .3 
    
    c = GW:InsertBar(5*k+5,"", Member.perMove, "green", "firebrick", false, GW.barStyles.gradientFixed + GW.barStyles.glass )
    c:WatchCaption  ("GroupList["..k.."].formattedMove")
    c:WatchValue ("GroupList["..k.."].perMove")
    c.gaugeHeight = c.cellHeight * .3 
    
    d = GW:InsertBar(6*k+6,Member.Tnl, 0)
    d.WatchCaption = ("GroupList["..k.."].Tnl")
    d.gaugeHeight = d.cellHeight * .3 
    
    e = GW:AddBar(Member.Align, 0)
    e.WatchCaption = "GroupList["..k.."].Align"
    e.gaugeHeight = e.cellHeight * .3 
  end -- if 
end -- function AddGroupmates


function UpdateLabels( )

  for k,Member in pairs (GroupList) do
    Member.formattedCap = ( HPFormat:format(Member.CurHp, Member.MaxHp) )
    Member.formattedMana = ( ManaFormat:format(Member.CurMana, Member.MaxMana) ) 
    Member.formattedMove = ( MoveFormat:format(Member.CurMove, Member.MaxMove) ) 
    Member.perHP = Member.CurHp / Member.MaxHp*100
    Member.perMana = Member.CurMana / Member.MaxMana*100
    Member.perMove= Member.CurMove / Member.MaxMove*100
  end
  GW:Update()

end


--Sample Data
GroupList = {
  {Name = "George", Status = "StandingG", CurHp = 100, MaxHp = 100, CurMove = 100, MaxMove = 100, CurMana = 10, MaxMana = 100, Tnl = 1000, Align = 1000, perHP = 0, perMana = 0, perMove=0, capHP="", capMana="", capMove="", } ,
  {Name = "Jane", Status = "StandingJ", CurHp = 90, MaxHp = 100, CurMove = 90, MaxMove = 100, CurMana = 20, MaxMana = 100, Tnl = 997, Align = 777, perHP = 0, perMana = 0, perMove=0, capHP="", capMana="", capMove="", } ,
  {Name = "Simba", Status = "StandingS", CurHp = 80, MaxHp = 100, CurMove = 80, MaxMove = 100, CurMana = 30, MaxMana = 100, Tnl = 887, Align = 666, perHP = 0, perMana = 0, perMove=0, capHP="", capMana="", capMove="", } ,
  {Name = "Banana", Status = "StandingB", CurHp = 70, MaxHp = 100, CurMove = 70, MaxMove = 100, CurMana = 40, MaxMana = 100, Tnl = 777, Align = 555, perHP = 0, perMana = 0, perMove=0, capHP="", capMana="", capMove="", } ,
}




Okay, back to casual lurking for another 3 years...
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sat 29 Nov 2014 08:21 PM (UTC)
Message
Just as well you posted here because your email ended up in my spam folder. Change incorporated:

https://github.com/nickgammon/mushclient/commit/a526743

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


2,482 views.

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]