This function will provide Mudlet users with easy access to "warning" style labels.
The function currently accepts two arguments, label name and label text. The function is called as standard, i.e.
It currently accepts two concurrent labels, with the second receiving a 75 pixel offset.
function visWarning(name, text)
local width, height = getMainWindowSize() -- Get our current window dimensions
local strLen = text:len() -- Find the character length of our "warning"
if windowExists == false then -- Does a warning window already exist?
createLabel(name, (width / 2) - 300, (height / 2) - 100, 250, 150, 1)
resizeWindow(name, strLen * 25, 70)
moveWindow(name, (width - (strLen * 25)) / 2, (height / 2) - 100) -- Dynamically place the window dependent on the length of our "warning"
windowExists = true
else
moveWindow(name, (width - (strLen * 25)) / 2, (height / 2) - 175)
end
setBackgroundColor(name, 255, 51, 51, 200)
echo(name, [[<p style="font-size:35px"><b><center><font color="white"> ]] .. text .. [[</font></center></b></p>]])
showWindow(name)
tempTimer(3, [[hideWindow("]] .. name .. [[");windowExists = false]]) -- Remove the window after 3 seconds
resetFormat()
end
As always, this code is provided, "as-is" - Should there be any glaring issues, please do report them on this thread.
Thanks, and enjoy!