Purpose: To highlight all captures in a multimatch in a specific color
Requirements: Multimatch trigger, not using 'highlight' checkbox
Code:local t = multimatches
for i=1, #t do
local out = {}
local n = t[i]
moveCursorEnd()
moveCursor(0, getLineNumber() - (#t - i))
if #n > 1 then
for j=2, #n do
local v = 1
while selectString( n[j], v ) ~= -1 do
table.insert( out, { selectString(n[j], v), #n[j] } )
v = v + 1
end
end
end
for i=1, #out do
local p = out[i]
local pos = p[1]
local len = p[2]
selectSection(pos, len)
-- potentially use a lookup table for specific positions here
fg('green')
deselect()
end
endOutput:
Sample trigger matched everything between 'Resources' & 'Organisations' and captured all numbers
"All we have to decide is what to do with the time that is given to us."
Comments
function IsTargetted(person) if not person then return end target = target or "Austere" if person == target then return true elseif string.findPattern(person, target) then return true else return false end endUses: Allows matches of partial targets. Target "Aust" would work in the following:Austere stands up.
^(\w+) stands up\.$<br><br>if IsTargetted(matches[2]) then<br> cecho("<cyan>\n\n"..target.. " IS NO LONGER PRONE. HE|SHE IS UP!!\n\n")<br>endfunction eventHandler(...)<br> display{...}<br>end<br>Svof
Mudlet Discord join up
stopwatch = stopwatch or createStopWatch()<br> startStopWatch(stopwatch)<br><br> [complicated code here]<br><br> echo(string.format("Code ran for %ss\n",getStopWatchTime(stopwatch)))Svof
Mudlet Discord join up
It can't completely avoid false positives(Hi, Antidas and Antonius), but it can avoid things like "Nazihk" and "Aziik".
- Use SVO?
- Hate the gem/veil changes?
- Got a chameleon tattoo?
If you want to, you can trigger the cham fading line afterwards to do:send("TOUCH CHAMELEON "..chamNameList[math.random(1, #chamNameList)])as well.What's it do? Simple. It fetches a list of names from ndb's database, from everyone you currently have tracked (noticed 0 lag whatsoever when I ran this, for reference. No worries there!), then touches your chameleon tattoo to a random name from that list.
If you call this over and over again before 5s, the timer will never fire. If you don't call it within 5s, it'll fire.
Svof
Mudlet Discord join up
All credit goes to Tysandr who wrote this in Imperian.
Locate Enemy Position local oldEchonums = mmp.echonums mmp.echonums = function(roomname) oldEchonums(roomname) local rooms = mmp.searchRoomExact(roomname) if not next(rooms) then echo "?" return nil end -- transform the kv table into a table of tables for cleaner code. -- + perhaps Mudlet in future will give this us anyway, sorted by relevancy local dt = {} for roomid,room in pairs(rooms) do dt[#dt+1] = {name = room, id = roomid} end jane.target.roomname = roomname jane.target.roomid = dt[1].id doblink( jane.target.roomid ) jane.target.area = getRoomAreaName(getRoomArea(jane.target.roomid)) end function roomIDExact(rname) local rooms = mmp.searchRoom(rname) local finalroom = {} for k, v in pairs(rooms) do if v == rname then table.insert(finalroom, k) end end return table.concat(finalroom, ", ") endThis is how I get the room id and area and store it within my own system and blink the rooms.Requirements: a table that contains the words to be excluded
Code:
s = string.gsnub(s, '(%w+)\.$', 'Tysandr.') ignorables = { 'mole' } -- requires 'ignorables' table string.gsnub = function(line,pattern,newPattern) line = string.gsub(line,pattern, function(str) if not table.contains(ignorables,str) then return newPattern end end) return line endOutput:
A couple of simple functions to pad a string with spaces so it matches a set length, truncating when the original string exceeds the specified length:
function string:padleft(length) if #self > length then return self:substring(1, length) end return string.rep(" ", length - #self) .. self end function string:padright(length) if #self > length then return self:substring(1, length) end return self .. string.rep(" ", length - #self) endResults of disembowel testing | Knight limb counter | GMCP AB files
Example:
<p>local t = {'Bob', 'Mary', 'Ann'}</p><p><br></p><p>print(concatand(t))</p><p><br></p>-- Bob, Mary, and Ann Svof
Mudlet Discord join up
Quality of life lua printf like, when string.format is too much to type every time
matching stuff for Charstats
function thisupdatesbleed() bleed = tonumber(string.match(gmcp.Char.Vitals.charstats[1], "%d+")) end registerAnonymousEventHandler("gmcp.Char.Vitals", "thisupdatesbleed")Can be used as a base for any of the charstats things although for monks stances/forms or other things with strings you'd have to use a different match (should be able to use "%w+: (%w+)" or something similar, there's a bunch of ways to matchand then a function that simply returns true if I'm in a party and false if I'm not for reporting purposes:
function amIinParty() local i for i = 1, #gmcp.Comm.Channel.List do if gmcp.Comm.Channel.List[i].name == "party" then return true end end return false endDunn tells you, "I hate you."
(Party): You say, "Bad plan coming right up."
mytable = mytable or {}Svof
Mudlet Discord join up
Would be very good for this thread.
Turns the "1" in gmcp into a true/false boolean. You can apply this trick elsewhere to set the variable without a long if.
Svof
Mudlet Discord join up
Results of disembowel testing | Knight limb counter | GMCP AB files
GMCP documentation: https://github.com/keneanung/GMCPAdditions
svof github site: https://github.com/svof/svof and documentation at https://svof.github.io/svof
<div>-- replace line from MUD with colour-tagged string creplaceLine = function(str) <span> </span>selectString(line,1) replace("") cinsertText(str) <span style="background-color: transparent; color: inherit; font-size: inherit; font-family: "lucida grande", "Lucida Sans Unicode", tahoma, sans-serif;">end</span></div>It accepts colour arguments, etc, just the same as a cecho, just a quick shorthand thing. Example usage:regex trigger: ^You rip the air from the lungs of (\w+) in a single instant\, blood and mucus dripping from h(?:is|er) mouth as (?:|s)he doubles over with hacking coughs\.$
creplaceLine("<white>[ASPHYXIATE]<reset> "..line)re: booleans - yes, but I find it helpful to be explicit in these things, esp. easier for beginners to read code.
Svof
Mudlet Discord join up
Purpose: Delete multiple lines below the trigger, up to the prompt.
Requirements: Know how many lines you want to delete. Uses global variable.
Code:
function deleteFull(howMany) deleteLine() local howMany = howMany or 1 mydeleter = true tempLineTrigger(1,howMany, [[ if not isPrompt() and mydeleter then deleteLine() else mydeleter = false end ]]) endInsert into ordered table t all the elements from ordered table nt.
Results of disembowel testing | Knight limb counter | GMCP AB files
Results of disembowel testing | Knight limb counter | GMCP AB files
cheatsheet = Geyser.Label:new({<br> name = "cheatsheet",<br> x = "30.5%", y = "65%",<br> width = "15%", height = "35%"<br>})<br><br>-- this determines the background color of the box<br>cheatsheet:setStyleSheet([[<br> background-color: rgba(0,50,0,25%);<br> border-radius: 6px;<br>]])<br><br>local t = {<br><br> {"dd", [[smite/DMG (+3)<br> knocks enemy off eq]]},<br> {"sta", "dart/DMG (+2)"},<br> {"man", [[manifest/DMG (-3)<br> scales on your wrath]]},<br> {"rep", [[reprisal (-3)<br> counter-attack]]},<br><br> {"---"},<br> {"sun", "dart/DMG (+3)"},<br> {"mn", "mend/HEAL (+2)"},<br> {"rqt", [[requital/DMG (-4)<br> dmg on low hp]]},<br> {"nv", [[vines (-2)]]},<br> {"la", [[lash (+2)<br> extra dmg on vined]]},<br> {"bm", [[balm (-2)<br> heals affs]]},<br> {"pol", [[pollen (+1)<br> slows down attackers]]},<br> {"sd", [[seed (+1)<br> saps curing]]},<br> {"ov", [[overgrowth<br> +resistances]]},<br> {"brm", [[brambles (-2)<br> dmg cage]]},<br> {"vit", [[vitansia<br> remote hp heal]]},<br> {"zai", [[zailet<br> remote aff heal]]},<br> {"rp", [[rapidgrowth<br> dmg]]},<br>}<br><br>local s = {}<br>for _, cmdt in ipairs(t) do<br> if cmdt[2] then<br> s[#s+1] = string.format([[<br> <span style="color:red; align:left;">%s:</span> <span style="color:green; align:left;">%s</span>]], cmdt[1], cmdt[2])<br> else<br> s[#s+1] = "<span>"..cmdt[1].."</span>"<br> end<br>end<br><br>cheatsheet:echo("<pre style=\"font-family: Ubuntu Mono; font-size:8pt;\"><strong>"..table.concat(s, "<br/>").."</strong></pre>")Svof
Mudlet Discord join up
A nicer looking qwho
Note, it requires knowledge of RGB values, which you can easily look up >>here<<.
Simply edit the script to add your colour, along the lines of
Then save script, and you'll be able to use 'myColour' in your code!
This also overrides the normal 'showColors()' function that's build into mudlet, with a much cleaner-looking layout, as seen below. You can use 'colours <num>' to show this, don't have to use lua like I did in the demonstration. I wouldn't recommend using a number greater than 5.