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, confirm your email, resolve issues, 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Cyote's InfoBox question

Cyote's InfoBox question

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


Posted by WillFa   USA  (525 posts)  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...
Top

Posted by Nick Gammon   Australia  (23,133 posts)  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
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.


12,818 views.

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.