Highlight & Gag Sets
Highlight and gag rules multiply fast. Keep them as data:
local highlights = { { pattern = "tells you", color = rune.style.cyan }, { pattern = "You are hit", color = rune.style.red }, { pattern = "levels up!", color = rune.style.green }, { pattern = "The sun rises", color = rune.style.yellow },}
for _, h in ipairs(highlights) do rune.trigger.contains(h.pattern, function(m, ctx) return h.color(ctx.line:clean()) end, { group = "highlights" })end
local gags = { "The barkeep polishes a glass", "A gentle breeze blows", "drops a piece of lint",}
for _, g in ipairs(gags) do rune.trigger.contains(g, nil, { gag = true, group = "gags" })endHow it works
Section titled “How it works”- A trigger handler that returns a string rewrites the line; here, the whole line is re-colored. Later triggers match against the rewritten text. See Triggers.
- A
nilaction withgag = truesilences the line with no handler at all. - The groups are the off switch:
/group gags offwhen you suspect you’re missing something,/group highlights offfor screenshots.
Variations
Section titled “Variations”Highlight only a word, not the line, by rewriting with a targeted replace:
rune.trigger.contains("gold coins", function(m, ctx) return (ctx.line:clean():gsub("gold coins", rune.style.yellow("gold coins")))end)Gag but count, to silence spam without losing information:
local swings = 0rune.trigger.contains("You swing at", function() swings = swings + 1 rune.ui.refresh_bars() return falseend, { group = "gags" })
rune.ui.bar("swings", function() return "swings: " .. swings end)rune.ui.layout({ bottom = { "swings", "input", "status" } })The layout line is required: a bar renders only if a layout dock names it.