Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| mudlet:bonus_gexp_capture_window [2026/10/08 15:44] – created taze | mudlet:bonus_gexp_capture_window [2026/10/12 19:47] (current) – taze | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Create a Window Script ===== | ===== 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 | - Connect to the MUD with your existing Mudlet profile | ||
| Line 5: | Line 6: | ||
| - Click the "add item" button to create a new script. | - Click the "add item" button to create a new script. | ||
| - Enter a name, like //" | - Enter a name, like //" | ||
| - | - In //"Add User Event Handler:"// | + | - In //"Add User Event Handler:"// |
| - Click the " | - Click the " | ||
| - | - Copy in the following source code to the text area.< | + | - Copy in the following source code to the text area.< |
| -------------------------------------------------- | -------------------------------------------------- | ||
| -- BONUS WINDOW | -- BONUS WINDOW | ||
| Line 15: | Line 16: | ||
| bonus_window = Geyser.UserWindow: | bonus_window = Geyser.UserWindow: | ||
| name = " | name = " | ||
| - | titleText = "BLURT BONUS", | + | titleText = "PARTY BONUS", |
| autoWrap = true, | autoWrap = true, | ||
| autoDock = false, | autoDock = false, | ||
| Line 30: | Line 31: | ||
| make_bonus_window() | make_bonus_window() | ||
| </ | </ | ||
| - | - Your scripts | + | - Your new or existing |
| - Click the "Save Item" button | - Click the "Save Item" button | ||
| + | - Create a new Perl Regex trigger | ||
| + | - Add the following regex < | ||
| + | - Add the following trigger lua <code lua> | ||
| + | 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: | ||
| + | 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, | ||
| + | |||
| + | -- Keep only last 25 visible bonuses | ||
| + | if # | ||
| + | table.remove(bonusXP.lines, | ||
| + | end | ||
| + | |||
| + | -------------------------------------------------- | ||
| + | -- FORMAT NUMBERS | ||
| + | -------------------------------------------------- | ||
| + | |||
| + | local function formatNumber(number) | ||
| + | |||
| + | local formatted = tostring(number) | ||
| + | |||
| + | while true do | ||
| + | local count | ||
| + | |||
| + | formatted, count = | ||
| + | formatted: | ||
| + | |||
| + | if count == 0 then | ||
| + | break | ||
| + | end | ||
| + | end | ||
| + | |||
| + | return formatted | ||
| + | end | ||
| + | |||
| + | -------------------------------------------------- | ||
| + | -- REDRAW WINDOW | ||
| + | -------------------------------------------------- | ||
| + | |||
| + | if bonus_window then | ||
| + | |||
| + | bonus_window: | ||
| + | |||
| + | -- Bonus history | ||
| + | for _, amount in ipairs(bonusXP.lines) do | ||
| + | |||
| + | bonus_window: | ||
| + | " | ||
| + | "< | ||
| + | " GXP\n" | ||
| + | ) | ||
| + | |||
| + | end | ||
| + | |||
| + | -- Footer | ||
| + | bonus_window: | ||
| + | " | ||
| + | ) | ||
| + | |||
| + | bonus_window: | ||
| + | " | ||
| + | "< | ||
| + | " | ||
| + | ) | ||
| + | |||
| + | bonus_window: | ||
| + | " | ||
| + | "< | ||
| + | " | ||
| + | ) | ||
| + | |||
| + | 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: | ||
| + | |||