===== Create a Window Script ===== **If you followed the [[Chat Capture Window]] steps 1-8 can be simplified by simply adding the function below that capture window** - Connect to the MUD with your existing Mudlet profile - Click the "scripts" button in the toolbar - Click the "add item" button to create a new script. - Enter a name, like //"Party Bonus Window"// - In //"Add User Event Handler:"// enter: sysConnectionEvent - Click the "+" button. - Copy in the following source code to the text area. -------------------------------------------------- -- BONUS WINDOW -------------------------------------------------- function make_bonus_window() bonus_window = Geyser.UserWindow:new({ name = "bonus_window", titleText = "PARTY BONUS", autoWrap = true, autoDock = false, x = "20%", y = "40%" }) bonus_window:setFontSize(getFontSize()) bonus_window:setFont(getFont("main")) return 1 end make_bonus_window() - Your new or existing scripts editor page should look like this: {{mudlet:partyscript.png}} - Click the "Save Item" button - Create a new Perl Regex trigger - Add the following regex party bonus grants you ([0-9,]+) guild experience - Add the following trigger lua bonusXP = bonusXP or { total = 0, count = 0, lines = {} } bonusXP.lines = bonusXP.lines or {} -------------------------------------------------- -- GET XP -------------------------------------------------- local xpText = matches[2] if not xpText then return end local cleanXP = xpText:gsub(",", "") local xp = tonumber(cleanXP) if not xp then return end -------------------------------------------------- -- UPDATE SESSION -------------------------------------------------- bonusXP.total = bonusXP.total + xp bonusXP.count = bonusXP.count + 1 table.insert(bonusXP.lines, xp) -- Keep only last 25 visible bonuses if #bonusXP.lines > 25 then table.remove(bonusXP.lines, 1) end -------------------------------------------------- -- FORMAT NUMBERS -------------------------------------------------- local function formatNumber(number) local formatted = tostring(number) while true do local count formatted, count = formatted:gsub("^(-?%d+)(%d%d%d)", "%1,%2") if count == 0 then break end end return formatted end -------------------------------------------------- -- REDRAW WINDOW -------------------------------------------------- if bonus_window then bonus_window:clear() -- Bonus history for _, amount in ipairs(bonusXP.lines) do bonus_window:cecho( " PARTY BONUS " .. "+" .. formatNumber(amount) .. " GXP\n" ) end -- Footer bonus_window:cecho( "\n--------------------------------\n" ) bonus_window:cecho( " SESSION GXP " .. "" .. formatNumber(bonusXP.total) .. "\n" ) bonus_window:cecho( " BONUSES " .. "" .. tostring(bonusXP.count) .. "\n" ) end - Click save trigger - The mudlet editor and new window should appear and look like the below. NOTE: the party bonus window is movable and sizable. It is setup to only display the last 25 captures. {{mudlet:partybonuscapture.png}} {{mudlet:partybonustrigger2.png}}