00:00:01.33
Good day. I'm going to demonstrate how to make a trigger in MUSHclient

00:00:05.43
and use that trigger to display a miniwindow.

00:00:08.60
Let's launch MUSHclient first and have a look at some example output.

00:00:14.10
In here I see I'm inside the Cathedral, and I want to capture my Exits line.

00:00:20.96
So I'll Shift + Double-click on that to select the whole line.

00:00:24.30
Copy that line ...

00:00:26.60
and go into my World Configuration, which is Alt + Enter

00:00:32.40
I'll check in the Scripts tab - to make sure my script prefix is set to a slash

00:00:37.33
and that Note Errors is checked - so that errors go to the output window.

00:00:42.13
Then in the Triggers section of the World Configuration I'll add a trigger,

00:00:47.63
paste in the line that I had just seen as an example and change that to ...

00:00:53.16
an asterisk for a wildcard.

00:00:56.60
Now I need to send that to Script, and to make editing the script easier I'll click on the Edit button

00:01:01.63
here - the dot dot dot (...).

00:01:04.66
Windows need a window ID so I'll call that "win = GetPluginID" ... now to get the spelling

00:01:14.00
and capitalization right I'll just click on the Complete button and choose GetPluginID

00:01:20.86
... put in the brackets to make that a function call and 

00:01:24.73
add ":exits" in case I have more than one window in this plugin.

00:01:29.96
And then I need a font ID for my font - I'll just call that "f".

00:01:34.23
Now I need to make a one-pixel by one-pixel window just to get my font height ...

00:01:41.13
so I'll say WindowCreate - press Alt+C to complete.

00:01:46.50
WindowCreate win ... now to look up the parameters for the WindowCreate I'll now put the cursor over that

00:01:53.46
and click on Functions - choose WindowCreate - and the help for WindowCreate will appear up here

00:01:59.86
in my help window. If I move the windows around I can view both at once.

00:02:05.56
Left, Top, Width, Height, the Position will be position 4 which will be in the top-left corner

00:02:12.20
Flags zero, and Colour we don't care about just now.

00:02:16.30
That will create our window which we are not going to use for very long

00:02:21.10
and we need to load into that a font.  WindowFont ... press Alt+C to complete

00:02:26.23
I want WindowFont - win - which is the window ID.  font - which is the font ID

00:02:32.10
and I'll try it in Courier, ah, 10-point Courier.

00:02:37.63
Now what we need to know is how high our 10-point Courier font is in pixels ...

00:02:42.13
so we'll grab the font height from WindowFontInfo.

00:02:50.86
And we want that window, that font, and if we click on WindowFontInfo and bring up the functions here

00:02:57.83
we can see that the height is number 1.

00:03:03.83
So I'll say "1".

00:03:05.96
And that will give me my font height.

00:03:08.06
Now I need to know how wide the text is so I can set up a window of the correct width.

00:03:13.26
So I'll say width = WindowText ... press Alt+C to complete again ...

00:03:20.30
WindowTextWidth for this window, this font, and the matching line, which is the Exits line.

00:03:31.60
Now we know the width and the height for our miniwindow we can create the window,

00:03:36.23
so I'll say WindowCreate again, ah, the window, position that at the top left corner

00:03:47.16
... in fact we are going to auto-position it so we don't care about those numbers.

00:03:51.03
We'll put in the width and the height, use number 4 to position in the top-left corner,

00:03:58.06
zero for the flags, and let's put a colour in ...

00:04:03.06
ColourName ... complete that ... ColourNameToRGB ... let's make the window green.

00:04:14.53
All that needs to be done now is to draw the text ... WindowText ... just press Complete to check

00:04:21.96
... yes I got the spelling and capitalization right there.

00:04:24.36
Window, font, we are going to use the matching line that the trigger was.

00:04:31.83
We want to go 5 pixels in and 5 pixels down, and use the rest of the window for the width and the height

00:04:40.83
And we'll do ColourName again ... ColourNameToRGB ... (I pressed Alt+C to do that) ...

00:04:49.36
I might do that in yellow.

00:04:59.50
And to show the window I'll do WindowShow ... win ... true.

00:05:04.40
Now I've got a couple of things wrong here ... I'm drawing 5 pixels in because I wanted to have the

00:05:11.80
text a bit offset from the side of the window, so I'll add 10 pixels to the width ...

00:05:17.43
and I'll add 10 pixels to the height. 

00:05:19.60
Right, let's try that out. We'll save that, save that, close that, and type in "look" ...

00:05:26.96
and see what happens.

00:05:28.33
There it is. There's the exits line, drawn in our miniwindow.

00:05:32.10
In yellow on green with a 5 pixel border around each side.

00:05:37.13
Now if I wanted to choose a different colour a useful thing to use is the Colour Picker.

00:05:44.76
So let's say well maybe I want a different background colour than green so I can go to Edit ...

00:05:50.36
Colour Picker ... and this shows the MUSHclient colour picker.

00:05:54.20
I might for a more earthy colour, let me see, we probably want a fairly dark colour

00:06:00.50
... what about, um, Sienna for example.

00:06:04.10
Now the ColourNameToRGB function will just accept the colour name, here in that box. 

00:06:08.43
So I'll just click on that box and that has copied "Sienna" onto the clipboard for me.

00:06:15.33
I'll press Alt+Enter, edit that trigger, click on that, and change the background

00:06:21.96
from green ... paste that in ... to Sienna.

00:06:27.43
Let's try again - and close all those.

00:06:29.90
There we are ... that doesn't look too bad.

00:06:33.03
And if we wanted to have the trigger text in bold

00:06:38.30
we could double-click that, click on that.

00:06:41.90
When we create the font the next argument along is whether it is bold, so I'll just change that to true.

00:06:50.00
Close those, "look" and now it's come out in bold.

00:06:54.66
I don't think that looks fabulous, personally, but it shows how easy it is to change the way it looks.

00:07:01.46
Now we'll see that if we move around the window instantly updates which is what we want.

00:07:09.20
Ah, I don't want to be somewhere, where it is pitch black.

00:07:12.00
You can see that miniwindow responds quickly to the room that we are in ...

00:07:17.23
and gives you an instant confirmation of what exits there are at that particular spot.

00:07:26.33
So that show how you can - with a simple trigger - produce a miniwindow that displays useful information

00:07:33.40
on the screen - this particular one doesn't let you drag the position of the miniwindow around with the mouse

00:07:39.50
... that takes a bit more code.

00:07:40.76
But it does illustrate how you can quickly show things like that - you could use something similar

00:07:47.06
to show your status, or the name of the room you're in or who your current target is. Things like that.

00:07:54.16
To find out more information about miniwindows go to the mushclient.com/mw site ...

00:08:03.76
and that shows you the introduction to miniwindows ...

00:08:06.46
which gives you some examples.

00:08:09.73
The creation information is under the "creating miniwindows section" which explains about WindowCreate

00:08:17.70
Drawing shapes: describes how you can draw things like circles, arcs, and polygons.

00:08:26.50
Drawing text: describes the basics of text, which I used here, which was to find the width of some text

00:08:41.16
and also things like the height of the font, which is that line there.

00:08:48.33
There's also a page about drawing images, so you can load images in and draw them in your window.

00:08:56.86
Adding hotspots which lets you process mouse clicks.

00:09:01.06
Graphic functions which let you change the background colour, or have a background image.

00:09:09.20
And, blending images which shows how you can combine images in different ways.

00:09:15.96
For example, you could overlay one image on top of another.

00:09:19.43
So that's all on the MUSHclient web site.

00:09:23.40
Thank you for watching.





