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.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Miniwindows/Infobox to track variables

Miniwindows/Infobox to track variables

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


Posted by Jai   (4 posts)  Bio
Date Mon 25 May 2009 04:33 AM (UTC)
Message
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?
Top

Posted by Nick Gammon   Australia  (23,100 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 25 May 2009 06:45 AM (UTC)

Amended on Mon 25 May 2009 06:50 AM (UTC) by Nick Gammon

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


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #2 on Mon 25 May 2009 07:33 AM (UTC)

Amended on Mon 25 May 2009 07:53 AM (UTC) by WillFa

Message
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. :)
Top

Posted by Jai   (4 posts)  Bio
Date Reply #3 on Mon 25 May 2009 07:17 PM (UTC)
Message
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!
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #4 on Tue 26 May 2009 01:11 AM (UTC)
Message
nope, you should be fine with that setup.

Glad you like the Infobox module. I put a lot of work into it. :)
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.


16,744 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.