Posted on February 14, 2022
Mudlet 4.15 Feature Highlight
In Short
This release of Mudlet can perhaps be summarized with two words; Sound and Labels. The Mudlet sound system saw an overhaul with this release opening up a lot of possibilities for ambient and background sounds. And there were several improvements to and around Labels; ability to display animated gif files, ability to resize themselves based on their content, a ScrollBox to contain them in a scrollable area for lists of labels or larger zoomed images and the like, c/d/hecho support for easily setting text formatting and color in Labels, and the new Geyser.StyleSheet for managing the stylesheets of your Labels for a more cohesive look.
Sound Overhaul
I don’t use the sound system in Mudlet much myself, so I reached out to the author of the overhaul to give me a couple paragraphs on it, so in the words of Tamarindo from the Mudlet discord:
New sound and music features were introduced with the Mudlet 4.15 release. The Mud Client Media Protocol (MCMP) uses Generic Mud Client Protocol (GMCP) to trigger playing of media files. Added are new optional parameters, “start”, “fadein” and “fadeout”.
Client.Media.Play {
"name": "monty_python.mp3", -- the track
"url": "https://yourdomainhere.com/music/", -- download and cache from here
"type": "music", -- music has difference features than sound in MCMP
"volume": 100, -- max volume
"start": 1000, -- start 1 second into the track
"fadein": 5000, -- raise the volume from the minimum to 100 over 5 seconds
"fadeout": 7000 -- begin to lower the volume 7 seconds before the track finishes from 100 to minimum volume
}
As you might expect, “start” instructs the client to begin playing the identified track at a specified number of milliseconds (1000 msec = 1 second). If one wants to progressively increase the volume from the start of the track over a period of time, they may now use “fadein”, which will use a linear algorithm to raise to volume until the number of milliseconds. Similarly, “fadeout” will reduce volume using a linear algorithm, but using the number of milleseconds specified from the end of the track as the starting point.
Additionally, the 4.15 release opens up all of the benefits of MCMP direct to the Lua API for Mudlet. Similar to the example above, one could define a table {} and do the following in a Mudlet script:
playMusicFile( {
name = "monty_python.mp3",
url = "https://yourdomainhere.com/music/",
volume = 100,
start = 1000,
fadein = 5000,
fadeout = 7000
} )
The API also offers these additional functions, loadMusicFile(), loadSoundFile(), playSoundFile(), stopMusic(), stopSounds() which also take a table as an argument. These take parameters as well, so playSoundFile(“”, 100) works as it has in earlier releases. If you have scripts that use playSoundFile today, you could now enhance them to specifically use the stopSounds(“”) function to have more control over your media. Please reference the Mudlet wiki for more information: https://wiki.mudlet.org/w/Manual:Miscellaneous_Functions or contact Tamarindo on the Mudlet Discord for more help.
Labels
Labels got a lot of improvements this release, but I’ll start with the additional support items added in this release
Geyser.StyleSheet
If you’re familiar with CSSMan then Geyser.StyleSheet should be immediately useful to you, as it has all the functionality of CSSMan and then some. Namely, you can assign a parent Geyser.StyleSheet to inherit properties from. This means you can set the border properties you know will be shared by a bunch of Labels in one Geyser.StyleSheet, and then use it as the parent for stylesheets which define the background color for related groups of Labels, and then use this second stylesheet as the parent for individual Labels which might each have their own font color, or some other individual trait. And then if you change the first label to make the border thicker, it will be inherited by all of the stylesheets all the way down. Check out the manual page for more details.
ScrollBox
Have a fancy who list with labels for the other players online, and not enough screen real estate to display it all? The ScrollBox gives you a container you can place Labels into which allows you to scroll either vertically or horizontally to view everything, but still keep it contained to a certain size on your actual screen. Example can be seen in the right side of this screenshot here from Tamarindo on the pull request which added the feature. Another good example from Edru for a zoomable map label can be seen here (mp4 file from discord).
Label auto resizing to fit contents
Another valuable addition from Edru, Labels can now tell you what size they should be, base on their contents. Using getLabelSizeHint Geyser.Labels can now auto adjust their width, height, or both based on these hints. Settings autoWidth or autoHeight to true will have Geyser automatically resize the label whenever you use its functions to change the text/images it displays. This is part of what allows for the zoomable map I linked to in the last section as well.
Get style information from a Label
This version of Mudlet also comes with the ability to query a Label for its style information. You can use getLabelStyleSheet and the Geyser equivalent to get the text stylesheet applied to the Label, if any. Or you can use getLabelFormat to get a format table in the same format as getTextFormat does for MiniConsoles. You can also use getBackgroundColor to get the background color set via setBgColor and the like for both Labels and MiniConsoles.
Can now play animated gif files
As shown in the following demo video by Vadi, you can now play animated gif movies in Mudlet! The package that drives this is available here. You could also potentially use it for stacking multiple state images (say, 28 different levels of fill for a highly stylized gauge) and setting the frame of the animation to the desired image.
cecho support
Once Vadi added support for Mudlet to tell us all about a Label’s styling, I set to work using that information in order to make cecho, decho, and hecho work with Labels, as one of the biggest drawbacks to Labels until now is that they would behave differently if you tried to cecho to them with the same text you sent to a MiniConsole. Sending mixed format text to a Label in particular required knowledge of html tags. Now you can use the same functions you would use with a MiniConsole in a Label and get text formatted in a familiar way.
The test I used while developing looked like this.
tl = Geyser.Label:new({name = "tl"})
tl:setStyleSheet([[
color: rgb(0,0,180);
border-width: 1px;
border-style: solid;
border-color: gold;
border-radius: 10px;
font-size: 12.0pt;
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #98f041, stop: 0.1 #8cf029, stop: 0.49 #66cc00, stop: 0.5 #52a300, stop: 1 #66cc00);
]])
decho("tl", "<128,0,128:0,128,128>This <b>is</b><i> a<r> tester <b>and so far<r> it seems to <128,128,128:0,0,0>pass")
Other improvements
- bold, overline, underline, italics, and strikethrough support in ansi2decho and c/d/hecho2ansi functions.
- getProfileStats returns a table listing the active, temp, and total number of triggers, aliases, etc for use in profiling your packages and optimizing things.
- windowType will tell you if it’s a MiniConsole, the main window, etc
- string.patternEscape will escape your string for use with Lua patterns
And more
As usual this is by no means an exhaustive list, but a selection of the things I want to highlight for one reason or another, but Mudlet is constantly evolving and changing and even I have a hard time keeping all the changes in mind.
Thanks for sticking with me through a longer than usual feature highlight, and thanks go out once again to Tamarindo for writing the sound section for me.
Happy MU*ing!