Need super basic MW guidance

Posted by Navazr on Thu 07 Nov 2013 01:50 AM — 11 posts, 38,422 views.

#0
Quick and simple:

I need to create a miniwindow to display the contents of a variable. In this case a target variable that will always be a single word name.

Would like it to show something like:

Current Target: <Name>

I've tried reading through all the help here on miniwindows and reading through some of these threads, but I can't seem to grasp even the basics of how to set one of these up. I think once I've got a basic miniwindow script like this in my hands I'll be able to learn how to manipulate it much easier.

Anything to get me going would be greatly appreciated!
Australia Forum Administrator #1
This video shows how to show the current exits in a miniwindow. Showing a variable would be very similar:



Amended on Tue 26 Nov 2013 01:07 AM by Nick Gammon
#2
Would this work for something that isn't triggered?

I'm currently using an alias to set my target variable, and then that variable is recalled in a bunch of other aliases.

I've got an alias to display the contents of the target variable in the output, but I was hoping to just use a miniwindow to constantly display that variable.
Australia Forum Administrator #3
The miniwindow part shows how to display some sort of short string.

You could, for example, do something similar inside a timer, and have that timer fire every second and find the value of the variable.
#4
Alright, seems way above my level of scripting competence!

Guess I'll just continue playing without miniwindows.

Thanks anyway.
Australia Forum Administrator #5
OK, here's an example:


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

var = GetVariable ("foo")

win = GetPluginID ( ) .. ":variable_contents"

font = "f"

WindowCreate ( win, 0, 0, 1, 1, miniwin.pos_top_left, 0, 0)

WindowFont ( win, font, "Courier", 10)

height = WindowFontInfo ( win, font, 1) + 10

width = WindowTextWidth ( win, font, var) + 10

WindowCreate ( win, 0, 0, width, height , miniwin.pos_top_left, 0, ColourNameToRGB ( "green" ))

WindowText ( win, font, var, 5, 5, 0, 0, ColourNameToRGB ( "yellow" ) )

WindowShow ( win )

    </send>
  </timer>
</timers>


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


That displays the contents of variable "foo" every 5 seconds on the top left corner.
Amended on Sun 10 Nov 2013 06:32 AM by Nick Gammon
#6
Alright, I had given up on the MiniWindow thing for quite a while until the other day I decided to give it another go.

Thanks so much for your example here. Using it I've been able to get something very close to what I was looking for.

This is what I've got currently (it's set up as a timer as you suggested):


var = GetVariable ("target")

win = GetPluginID ( ) .. ":variable_contents"

font = "f"

name = "TargetWindow" .. GetPluginID ( )

WindowCreate ( win, 0, 0, 1, 1, miniwin.pos_bottom_center, 0, 0)

WindowFont ( win, font, "Courier", 6, true)

height = WindowFontInfo ( win, font, 1) + 10

width = WindowTextWidth ( win, font, var) + 10

WindowCreate ( win, 0, 0, 250, 25, miniwin.pos_bottom_center, 0, 0x333333)

WindowRectOp( win, miniwin.rect_draw_edge, 2, 2, -2, -2, miniwin.rect_edge_etched, miniwin.rect_edge_at_all)

WindowText ( win, font, "Current Target:", 5, 5, 0, 0, ColourNameToRGB ( "green" ) )

WindowText ( win, font, var, 150, 5, 0, 0, ColourNameToRGB ( "red" ) )

WindowShow ( win )


What I'm trying to do now is figure out how to manually set it's location instead of just using the generic top/bottom left/center/right function. I'm also a bit confused as to why there are two WindowCreates in there.

I've tried just adjusting the top and left values in the WindowCreate function, but it doesn't seem to do anything. And when I cut out the miniwin.pos it just returns an error every time it tries to draw the window.

Here's the window position at bottom_center:

http://s29.postimg.org/e0bp30sit/Mini_Window.jpg

It's offset quite a bit, I'm assuming because of the health bar plugin I've got installed. Though when I set it to Bottom_left it just dumps it right over the health bars.

Any advice?

Thanks in advance!
Amended on Sun 01 Dec 2013 01:18 AM by Navazr
#7
Nevermind, literally 15 seconds after the previous post I found the miniwin.create_absolute_location in the miniwindow help pages!

Sorry about that!
#8
Alright, another question! =P

Is there a way to create a second window using a timer? I tried setting up a second window on a timer like the previous one, but mush kept alternating between the two windows (the first would disappear when the second was drawn, and the second would disappear when the firsts timer was up and it was redrawn).

I just copied/pasted the previous windows code and put in a different name.

Is there something else I need to do to allow both windows to be drawn at the same time?
Australia Forum Administrator #9
You would need a different window name (the "win" variable). Also make sure you call the variable itself something else, or you will replace the previous value.

eg.


win2 = "my_other_window"


Then use win2 in place of win in the other timer.

You can have lots of miniwindows.
#10
Great!

Sorry for all the questions that probably seem extremely simple to someone like you! I'm just getting my feet wet here though.

I'm sure I'll have more questions as I try to do more complex stuff than just displaying some variable contents, but I'll do my best to scour all the resources here before asking.

Thanks again for all your help!!!