Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
mudlet:bonus_gexp_capture_window [2026/10/08 15:44] – created tazemudlet: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 //"Party Bonus Window"//   - Enter a name, like //"Party Bonus Window"//
-  - In //"Add User Event Handler:"// enter: <code>sysConnectionEvnet</code>+  - In //"Add User Event Handler:"// enter: <code>sysConnectionEvent</code>
   - Click the "+" button.   - Click the "+" button.
-  - Copy in the following source code to the text area.<code>+  - Copy in the following source code to the text area.<code lua>
 -------------------------------------------------- --------------------------------------------------
 -- BONUS WINDOW -- BONUS WINDOW
Line 15: Line 16:
   bonus_window = Geyser.UserWindow:new({   bonus_window = Geyser.UserWindow:new({
     name = "bonus_window",     name = "bonus_window",
-    titleText = "BLURT BONUS",+    titleText = "PARTY BONUS",
     autoWrap = true,     autoWrap = true,
     autoDock = false,     autoDock = false,
Line 30: Line 31:
 make_bonus_window() make_bonus_window()
 </code> </code>
-  - Your scripts setting pages should now look exactly like this: {{mudlet:partybonuscapture.png}}+  - Your new or existing scripts editor page should look like this: {{mudlet:partyscript.png}}
   - Click the "Save Item" button   - Click the "Save Item" button
 +  - Create a new Perl Regex trigger
 +  - Add the following regex <code>party bonus grants you ([0-9,]+) guild experience</code>
 +  - Add the following trigger lua <code 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(
 +      "  <gray>PARTY BONUS   " ..
 +      "<gold>+" .. formatNumber(amount) ..
 +      " GXP\n"
 +    )
 +
 +  end
 +
 +  -- Footer
 +  bonus_window:cecho(
 +    "\n<dim_gray>--------------------------------\n"
 +  )
 +
 +  bonus_window:cecho(
 +    "  <green>SESSION GXP    " ..
 +    "<white>" .. formatNumber(bonusXP.total) ..
 +    "\n"
 +  )
 +
 +  bonus_window:cecho(
 +    "  <green>BONUSES        " ..
 +    "<white>" .. tostring(bonusXP.count) ..
 +    "\n"
 +  )
 +
 +end</code>
 +
 +- 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}}
 +