Releases: demonnic/MDK
Echo the contents of a file, string interpolation
Adds a new file, echofile.lua
Primarily, this module contains functions for echoing file contents, but I decided to add interpolation/templating to it because
- I'm tired of not having string interpolation
- It makes it more useful for dynamic page generation using templates
- I'm tired of not having string interpolation (not a typo, I'm that tired of it)
As an example, take the following file contents in file getMudletHomeDir() .. "/hechotest"
#ff0000 #ff0b00 #ff1600a#ff2000 #ff2b00l#ff3600u#ff4000m#ff4b00i#ff5600n#ff6000e#ff6b00s#ff7600c#ff8000ent#ff8c00 #ff9800b#ffa300u#ffaf00t#ffba00t#ffc600e#ffd100r#ffdd00f#ffe800l#fff400y#ffff00 fl#e8ff00o#d1ff00a#baff00t#a3ff00s#8cff00 #74ff00a#5dff00b#46ff00o#2fff00u#18ff00t#00ff00 la#00ff18z#00ff2fi#00ff46l#00ff5dy#00ff74 #00ff8co#00ffa3n#00ffba #00ffd1b#00ffe8r#00ffffill#00f4ffa#00e8ffn#00ddfft#00d1ff #00c6ffb#00baffl#00afffu#00a3ffe#0098ff #008cffa#0080ffnd #0c75ffl#1869ffi#235effl#2f52ffa#3b46ffc#463bff #522fffw#5e23ffi#6918ffn#750cffg#8000ffs
{GM.hgradient(" a luminescent butterfly floats about lazily on brillant blue and lilac wings\n", {255,0,0}, {0,0,255})}
You can output the following using hechoFile(f"{getMudletHomeDir()}/hechotest")
if you've installed the functions globally and have the gradientmaker in GM. https://demonnic.github.io/mdk/1.1.4/modules/echofile.html has more info
TextGauge overflow support
Buffer Size adjustments for EMCO
Adds the following constraints to EMCO:
- bufferSize
- how many lines to hold in the buffer. Defaults to 100000
- deleteLines
- when the buffer does fill up, how many lines to delete? Defaults to 1000.
Also adds EMCO:setBufferSize(bufferSize, deleteLines)
to adjust these values after creating the EMCO.
Also resolves #9
Add replay and replayAll functions to EMCO
For replaying the last X lines into an emco tab/all emco tabs.
myEMCO:replay("CT", 10) -- reads the last ten lines from the CT tab's log and plays them into the console
myEMCO:replayAll(10) -- reads the last 10 lines from the logs for all tabs and plays them into the console
Logging and Command lines and Background Pics OH MY!
To go along with the Mudlet 4.10 release, have:
demontools.lua
collection of useful functions which I use multiple places or do not fit in another class per se. Color converting functions, mkdir_p functionality, getValueAt (used to turn "gmcp.Char.Vitals" into the actual gmcp.Char.Vitals table), and others.
loggingconsole.lua
- Do you want your miniconsole to log itself? OF COURSE YOU DO! Put this on your plate and eat it up then.
- Supports all the Geyser.MiniConsole goodness you're used to. HELL YEAH!
- Adds new templated constraints path and fileName. Allows you to setup automated rotation by replacing |y with year, |m with the month as 2 digits, |d with the day of the month as two digits, |n as the name of the miniconsole, |e as the file extension(base on logFormat) and |h as the output of getMudletHomeDir(). So if your path is "|h/log/consoleLogs/|y/|m|d" and your fileName is "|n.|e" then your logs will daily rotate into new folders without you having to worry about it.
- Adds logFormat constraint. "h" logs in html, "l" logs in ansi colored log format, "t" logs in plain text.
- generate html verified readable on ada-young
Command line, background image, and logging support for EMCO
I added support for the miniconsole command lines and background images to EMCO. I find it best to perhaps show with an example.
The following 48 lines of code create a set of chat tabs in an adjustable container with gmcp message handling in Lusternia, including logging, sending the commandline from CT to the ct channel, the CGT commands to the CGT channel, and a background image. Picture below, showing the image and the different 'modes' (same as Mudlet's setBackgroundImage for miniconsoles.)
local EMCO = require("MDK-1.EMCO")
emcoContainer = emcoContainer or Adjustable.Container:new({name = "EMCOCon"})
chatEMCO = EMCO:new({
name = "Chatbox",
x = 0,
y = 0,
height = "100%",
width = "100%",
consoles = { "All", "CT", "CGT", "Tells", "Misc", "Map" },
allTab = true,
allTabName = "All",
mapTab = true,
mapTabName = "Map",
blankLine = true,
blink = true,
timestamp = true,
fontSize = 12,
commandLine = true,
cmdActions = {
CT = "ct |t",
CGT = function(txt) send("cgt " .. txt) end,
},
backgroundImages = {
CT = {
image = "/home/demonnic/Pictures/i-am-the-mud-client-now.png",
mode = "center"
}
}
}, emcoContainer)
local function chatCapture()
local info = gmcp.Comm.Channel.Text
valid_consoles = table.deepcopy(chatEMCO.consoles)
if info.channel:starts("tell ") then
info.channel = "Tells"
elseif not table.contains(chatEMCO.consoles, info.channel:upper()) then
debugc("GMCP channel that isn't in console list: " .. info.channel)
info.channel = "Misc"
else
info.channel = info.channel:upper()
end
local txt = ansi2decho(info.text)
chatEMCO:decho(info.channel,txt)
end
if chatCaptureEventID then
killAnonymousEventHandler(chatCaptureEventID)
end
chatCaptureEventID = registerAnonymousEventHandler("gmcp.Comm.Channel.Text", chatCapture)
Minor fix for SortBox
The debugc message when sortbox tried to handle elasticity with a dynamic item inside had an out of place paranthesis. This just quickly wraps that up.
EMCO Tab text formatting options
Adds the following constraints to EMCO, as well as the functions to interact with them:
- tabUnderline and enable/disable functions
- set true to underline the tab text
- tabBold and enable/disable functions
- set true to embolden the tab text
- tabItalics and enable/disable functions
- set to true to italicize the tab text
- tabFontSize and a setter function
- set to the desired font size for the tabs. Defaults to 8
- tabAlignment and a setter function
- set to the desired alignment of the tab text. Defaults to center.
EMCO: Add timestampExceptions to turn timestamps off on a per-tab basis
You (well, one person) asked for it, now you have it! Adds the timestampExceptions constraint which is a table of the tab names which should not have timestamps. IE to exclude a tab from timestamping when you make the EMCO add timestampExceptions = { "Guild" },
to the constraints and the Guild tab will not get timestamps.
Also adds EMCO:addTimestampException(tabname) and EMCO:removeTimestampException(tabName) to control this after creation.
timestampExclusions will be saved/loaded if you use EMCO:save() and EMCO:load()
Self Updating Gauges
Tired of calling setValue all the time? Just want to tell your gauge what variables to watch and have it figure out all that crap? Bonus if it will update the text as well? Self Updating Gauges are for you!
They're not really all that different from Geyser.Gauge, which the self updating gauges extend. The following code creates a health gauge which will monitor the variable gmcp.Char.Vitals.hp for the current value and gmcp.Char.Vitals.maxhp as the max value.
require("MDK-1.sug") --the following will watch "gmcp.Char.Vitals.hp" and "gmcp.Char.Vitals.maxhp" and update itself every 333 milliseconds
myGauge = SUG:new({
name = "myGauge",
currentVariable = "gmcp.Char.Vitals.hp", --if this is nil, it will use the defaultCurrent of 50
maxVariable = "gmcp.Char.Vitals.maxhp", --if this is nil, it will use the defaultMax of 100.
height = 50,
})
SUGs will use tonumber to coerce a variable to a number if possible, so your string gmcp values will be turned into numbers for use by the gauge without you having to do it.
Add :display() and :removeTab to EMCO
This is a relatively small release. It adds EMCO:display(tabName, thing) which works like display() but outputs to the EMCO tab.
Also adds EMCO:removeTab(tabName) which allows for removing a tab from EMCO.