Hey all,
I made the below alias to assist with finding things when looking at old news. It basically just augments the SEARCHNEWS command in-game to remember what you search for, then later highlight any occurrence of that word or phrase. I didn't want things scattered around too much between aliases/triggers/scripts, so everything is self-contained in the alias. Once everything is in place and working, you can
SEARCHNEWS CLEAR HIGHLIGHT to clear any existing highlight you've got set.
Here's a sample of the output:
SEARCHNEWS Command Output- Create a new Alias in Mudlet, give it a good name such as "I love Malaphus" or "SEARCHNEWS", etc.
- Paste the following into the PATTERN textbox:
(?i)^\s*searchnews(?: ([a-zA-Z]+))(?: ([ASB]))?(?: ([0-9]+))?(.+)
- Paste the following into the script area:
--
-- Author: Malaphus
--
-- Settings:
local searchHighlightColor = "yellow"
-- END Settings. Don't edit things below this line unless you know how to not break stuff.
lastNewsSearch = matches[5]:trim():lower()
if matches[2] == "clear" and lastNewsSearch == "highlight" then
if newsHighlightTrigger then
cecho("Searchnews highlight has been cleared.\n")
killTrigger(newsHighlightTrigger)
newsHighlightTrigger = nil
else
cecho("Searchnews highlight has was not set.\n")
end
send("\n", false)
return
end
newsHighlightFunction = newsHighlightFunction or function (term, color)
local c, k = 1, 1
while k > 0 do
k = line:lower():find(term, k)
if k == nil then
return
end
c = c + 1
from, how_long = line:lower():find("%f[%a]"..term.."%f[%A]", k)
if from then
if selectSection(k-1, how_long - k + 1) then
fg(color)
resetFormat()
else return end
end
k = from + 1
end
end
if newsHighlightTrigger then
killTrigger(newsHighlightTrigger)
newsHighlightTrigger = nil
end
newsHighlightTrigger = tempRegexTrigger("(?i:" .. lastNewsSearch .. ")", ([[newsHighlightFunction("%s", "%s")]]):format(lastNewsSearch, searchHighlightColor))
send(matches[1], false)
cecho("\nSearch Term: <" .. searchHighlightColor .. ">" .. lastNewsSearch .. "\n\nSearch Results:\n\n")
I hope other people find it useful!
-Malaphus
Comments
Thanks!
Have to put two spaces after the news section I'm looking in;
searchnews announce bullet
searchnews announce bullet
-- -- Author: Malaphus -- -- Settings: local searchHighlightColor = "yellow" -- END Settings. Don't edit things below this line unless you know how to not break stuff. lastNewsSearch = matches[5]:trim():lower() if matches[2] == "clear" and lastNewsSearch == "highlight" then if newsHighlightTrigger then cecho("Searchnews highlight has been cleared.\n") killTrigger(newsHighlightTrigger) newsHighlightTrigger = nil else cecho("Searchnews highlight has was not set.\n") end send("\n", false) return end newsHighlightFunction = newsHighlightFunction or function (term, color) local c, k = 1, 1 while k > 0 do k = line:lower():find(term, k) if k == nil then return end c = c + 1 from, how_long = line:lower():find("%f[%a]"..term.."%f[%A]", k) if from then if selectSection(k-1, how_long - k + 1) then fg(color) resetFormat() else return end end k = from + 1 end end if newsHighlightTrigger then killTrigger(newsHighlightTrigger) newsHighlightTrigger = nil end newsHighlightTrigger = tempRegexTrigger("(?i:" .. lastNewsSearch .. ")", ([[newsHighlightFunction("%s", "%s")]]):format(lastNewsSearch, searchHighlightColor)) send(matches[1], false) cecho("\nSearch Term: <" .. searchHighlightColor .. ">" .. lastNewsSearch .. "\n\nSearch Results:\n\n")