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
➜ Lua
➜ Dynamic Buff Indicator
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Solaobajiuik
(7 posts) Bio
|
Date
| Wed 05 Oct 2016 06:39 PM (UTC) |
Message
| I saw that a Forum User named Jarvis actually got one working with the bar's being removed/added instead of staying on the screen. Does anyone have something that will do this dynamic like that? I'm trying to write one myself, however, I am having problems getting the bar's to remove themselves.
require "InfoBox"
box = InfoBox:New("ARMOR")
buffs = box:AddBar("Buffs")
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
function buff_on (spell)
buffs = box:AddBar(spell, 100, "darkgreen")
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
end
function buff_off (spell)
buffs = box:AddBar(spell, 100, "darkred")
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
end
| Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #1 on Wed 05 Oct 2016 08:58 PM (UTC) |
Message
| You mean, buff_off should make the bar go away? Or the whole thing? See "RemoveBar" in the documentation. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Solaobajiuik
(7 posts) Bio
|
Date
| Reply #2 on Wed 05 Oct 2016 10:24 PM (UTC) |
Message
| The way I read the documentation buff_off would need to be
function buff_off (spell)
buffs = box:RemoveBar(1)
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
end
But, what I am trying to do is
function buff_off (spell)
buffs = box:RemoveBar(spell)
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
end
Or some way to figure out what the numeric value of the bar of that spell name is. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #3 on Thu 06 Oct 2016 04:28 AM (UTC) |
Message
| As you add new buffs the new one is added to a table. If you do this you will see it:
require "tprint"
tprint (box)
Amongst other things you see:
"Bars":
1:
"matteShadow"=5131854
"cellLeft"=0
"cellTop"=6
"id"=1
"captionPlacement"=4
"matteHilight"=11711154
"caption"="Buffs"
2:
"id"=2
"goodColour"=25600
"cellLeft"=0
"matteShadow"=5131854
"value"=100
"cellTop"=31
"matteHilight"=11711154
"caption"="bar"
My caption was "bar" in this case.
You could iterate through that table to find the id number like this:
local index = nil
for k, v in ipairs (box.Bars) do
if v.caption == "bar" then -- or whatever caption you want
index = v.id
break
end -- if
end -- for
print ("ID for bar is ", index)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Solaobajiuik
(7 posts) Bio
|
Date
| Reply #4 on Thu 06 Oct 2016 12:21 PM (UTC) |
Message
| Alright, So I got that working now. Thanks Nick! Last thing to do is find out if its possible to drag+move InfoBars. I've love to be able to move the miniwindow around by clicking on the header.
It doesn't sound like InfoBars are moveable. It's all based on the initial placement.
require "InfoBox"
box = InfoBox:New("ARMOR")
buffs = box:AddBar("Buffs")
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
function buff_on (spell)
local barID = getbarID(spell)
if barID ~= nil then
buffs = box:RemoveBar(barID)
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
end
end -- buff_on
function buff_off (spell)
buffs = box:AddBar(spell, 100, "darkred")
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
end -- buff_off
function getbarID (caption)
require "tprint"
local index = nil
for k, v in ipairs (box.Bars) do
if v.caption == caption then
index = v.id
break
end -- if
end -- for
return index;
end -- getbarID
| Top |
|
Posted by
| Solaobajiuik
(7 posts) Bio
|
Date
| Reply #5 on Thu 06 Oct 2016 12:53 PM (UTC) |
Message
| And of course.. to make it look sexier and readable :) | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #6 on Thu 06 Oct 2016 07:54 PM (UTC) |
Message
| You don't need the "tprint" line there, that was just for debugging.
To move the window (bar) see this post:
http://www.gammon.com.au/forum/?id=9594
Add these three lines to after "box:Update()" and you can then drag the bar window around:
require "movewindow"
windowinfo = movewindow.install (box.windowName, miniwin.pos_center_right, 0) -- default position / flags
movewindow.add_drag_handler (box.windowName, 0, 0, 0, 0, miniwin.cursor_both_arrow)
With slightly more work you can get it to remember where you left the bar last time and put it back there - see the post above for more details. |
- 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.
19,395 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top