This is an old revision of the document!


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

  1. Connect to the MUD with your existing Mudlet profile
  2. Click the “scripts” button in the toolbar
  3. Click the “add item” button to create a new script.
  4. Enter a name, like “Party Bonus Window”
  5. In “Add User Event Handler:” enter:
    sysConnectionEvnet
  6. Click the “+” button.
  7. 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()
  8. Your scripts setting pages should now look exactly like this:
  9. Click the “Save Item” button
  10. Create a new Perl Regex trigger
  11. Add the following regex
    party bonus grants you ([0-9,]+) guild experience
  12. 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(
          "  <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

- 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.