Miniwindows/Infobox to track variables

Posted by Jai on Mon 25 May 2009 04:33 AM — 5 posts, 22,205 views.

#0
Is there a quick way to keep track of what a variable is without looking it up in the list of variables? I have several targets set at once for different types of skills- I can make the variables and the aliases to set them- and I'd like a way to keep track of who I have targeted for what. I thought I could use the infoboxes/miniwindows for this, but it's not working out. I've been trying in Lua with:

require "InfoBox"
box = InfoBox:New("TW")
box:WindowPosition(box.windowPositions.E)
tw = box:AddBar("KT: (string.sub(GetVariable("kill_target")))"), 100, "gray", "gray", false, InfoBox.barStyles.solid)
tw = box:AddBar("HT: (string.sub(GetVariable("heal_target")))"), 100, "gray", "gray", false, InfoBox.barStyles.solid)
tw = box:AddBar("DT: (string.sub(GetVariable("debate_target")))"), 100, "gray", "gray", false, InfoBox.barStyles.solid)
box:Update()

or

require "InfoBox"
box = InfoBox:New("TW")
box:WindowPosition(box.windowPositions.E)
tw = box:AddBar("KT: ", GetVAriable("kill_target"))
tw = box:AddBar("HT: ", GetVAriable("heal_target"))
tw = box:AddBar("DT: ", GetVAriable("debate_target"))
box:Update()

Am I doing the scripts wrong or should I be trying to use something besides infoboxes?
Australia Forum Administrator #1
One problem I see is that this will only show the current value, and it won't update (unless you are planning to put this inside a timer). Infoboxes, as far as I know, are for gauges rather than pure text (I could be wrong about that).

This timer I developed shows how you can just display the various variables you mention, in a small miniwindow. It updates every second, so it should show the current information.


<timers>
  <timer enabled="y" second="1.00" send_to="12"
>
  <send>

require "var"

-- make window if required
if not setup_target_window then

  target_win = GetPluginID () .. ":targets" -- get a unique name
  WindowCreate (target_win , 0, 0, 200, 55, 6, 0, ColourNameToRGB("whitesmoke"))  -- create window

  WindowFont (target_win, "f", "FixedSys", 9) -- define font
  target_font_height  = WindowFontInfo (target_win , "f", 1)  
  setup_target_window = true

end -- if first time

-- blank existing window contents

WindowRectOp (target_win, 2, 0, 0, 0, 0, WindowInfo (target_win, 9))

-- framing rectangle
WindowRectOp (target_win, 5, 0, 0, 0, 0, 5, 15)

-- variables for text position (the top updates as we move down)
local left = 5
local top = 5

-- kill target
WindowText (target_win, "f", "KT: " .. (var.kill_target or "none"), 
            left, top, 0, 0, ColourNameToRGB("green"))

top = top + target_font_height  

-- heal target
WindowText (target_win, "f", "HT: " .. (var.heal_target or "none"), 
            left, top, 0, 0, ColourNameToRGB("blue"))

top = top + target_font_height  

-- debate target
WindowText (target_win, "f", "DT: " .. (var.debate_target or "none"), 
            left, top, 0, 0, ColourNameToRGB("orange"))

-- make visible, or refresh if already visible
WindowShow (target_win ,  true)  

</send>

  </timer>
</timers>

Amended on Mon 25 May 2009 06:50 AM by Nick Gammon
USA #2
As Nick said, that needs a timer to keep it updated.


The big problem above though is how you were trying to make the caption.

This should work better for you:


<timers>
  <timer enabled="y" second="15.00" offset_second="0.00"    send_to="12"
>
  <send>require "InfoBox"
box = box or InfoBox:New("TW")
box.Bar.barStyle = InfoBox.barStyles.textOnly
box:WindowPosition(box.windowPositions.E)
tw = box.Bars[1] or box:AddBar("")
tw.caption = "KT: " .. GetVariable("kill_target") 
tw = box.Bars[2] or box:AddBar("")
tw.caption = "HT: " .. GetVariable("heal_target") 
tw = box.Bars[3] or box:AddBar("")
tw.caption = "DT: " .. GetVariable("debate_target") 
box:Update()</send>

  </timer>
</timers>


p.s. nick, it's possible to have a "bar" that's just a label. :)
Amended on Mon 25 May 2009 07:53 AM by WillFa
#3
Wow, such fast replies, thanks!

I went with Willfa's because I understand it a little better and it's working great. Instead of putting it on a timer, I put it to an alias. I've a trigger to set off the alias when I join the game, and my alias to set a target variable also triggers the updating alias. If for some reason this way would cause problems and I should use a timer, please let me know!
USA #4
nope, you should be fine with that setup.

Glad you like the Infobox module. I put a lot of work into it. :)