Mudlet Code Snippets - post any useful ones you might have here!

24

Comments

  • edited December 2016
    For all of you terrible people who like rainbow crits. I decided to make one out of pure boredom (and summarily delete it >.>)

    Trigger - Perl Regex
    ^You have scored (a|an) (.+)!$

    Code:
    local X
    local L = ""
    local C = {"red", "orange", "yellow", "green", "blue", "purple", "pink", "cyan",}
    for token in matches[1]:gmatch("[^+]") do
       X = math.random(1, #C)
       L = L.."<"..col[X]..">"..token
    end
    deleteLine()
    cecho("\n"..L)
    Add any colour you want to the C table.
    Email:        el.ni93@hotmail.com
    Discord:    Rey#1460
  • TremulaTremula Banished Quasiroyal
    Reylari said:
    For all of you terrible people who like rainbow crits. I decided to make one out of pure boredom (and summarily delete it >.>)

    Trigger - Perl Regex
    ^You have scored (a|an) (.+)!$

    Code:
    local X
    local L = ""
    local C = {"red", "orange", "yellow", "green", "blue", "purple", "pink", "cyan",}
    for token in matches[1]:gmatch("[^+]") do
       X = math.random(1, #C)
       L = L.."<"..col[X]..">"..token
    end
    deleteLine()
    cecho("\n"..L)
    Add any colour you want to the C table.
    Going to change this to be more friendly to mine and Cyndarin's colourblindness and then add it to my crit counter. Thank you very much! <3
                          * * * WRACK AND ROLL AND DEATH AND PAIN * * *
                                         * * * LET'S FEEL THE FEAR OF DEATH AGAIN * * *
              * * * WE'LL KILL AND SLAUGHTER, EAT THE SLAIN * * *
      * * * IN RAVAGING WE'LL ENTERTAIN * * *

    Ixion tells you, "// I don't think anyone else had a clue, amazing form."
  • So I saw Reylari's script and thought to myself; why stop at crits? Why not make everything rainbow?

    Behold: https://ada-young.appspot.com/pastebin/0zBRjenF

    Make a script:
    function rainbow(text, mode)<br>  local str = ""<br>  local colourtable = { <br>    {"|cD22A2A","|cD2542A","|cD27E2A","|cD2A800","|cD2D200","|cA8D200","|cA8A800","|cA8A82A","|c7EA82A","|c54A82A","|c2AA82A","|c2A7E2A","|c2A7E54","|c007E54","|c007E7E","|c007EA8","|c0054A8","|c00547E","|c002A7E","|c2A2A7E","|c542A7E","|c7E2A7E"}, -- rainbow<br>    {"|c2A2A54","|c54547E","|c7E7EA8","|cA87EA8","|cD2A8A8","|cD2A8A8","|cD2A8A8","|cA87EA8","|c7E7EA8","|c547EA8","|c7E7EA8","|c54547E"} -- dawn<br>  }<br>  local colours = {}<br><br>  if mode > #colourtable then<br>    colours = colourtable[1] <br>  else <br>    colours = colourtable[mode]<br>  end<br><br>  local i = math.random(#colours)<br><br>  for char in text:gmatch(".") do<br>    if char == " " then<br>      str = str .. char<br>    else<br>      str = str .. colours[i] .. char<br>      if i == #colours then i = 0 end<br>      i = i + 1<br>    end<br>  end<br><br>  return hecho(str)<br>end
    Then you can call it using:
    rainbow("Blah blah blah", 1)

    1 is for rainbow, 2 is for dawn.
  • TremulaTremula Banished Quasiroyal
    Why are there so many fonts about rainbows?
                          * * * WRACK AND ROLL AND DEATH AND PAIN * * *
                                         * * * LET'S FEEL THE FEAR OF DEATH AGAIN * * *
              * * * WE'LL KILL AND SLAUGHTER, EAT THE SLAIN * * *
      * * * IN RAVAGING WE'LL ENTERTAIN * * *

    Ixion tells you, "// I don't think anyone else had a clue, amazing form."
  • Do you mean colours? I just got those from the colours of the Hallifax belljar. I think the rainbow scarf also uses that colour scheme.
  • TremulaTremula Banished Quasiroyal
    The correct response was 'And what's on the other side'. (Muppets reference <_<)
                          * * * WRACK AND ROLL AND DEATH AND PAIN * * *
                                         * * * LET'S FEEL THE FEAR OF DEATH AGAIN * * *
              * * * WE'LL KILL AND SLAUGHTER, EAT THE SLAIN * * *
      * * * IN RAVAGING WE'LL ENTERTAIN * * *

    Ixion tells you, "// I don't think anyone else had a clue, amazing form."
  • TremulaTremula Banished Quasiroyal
    Gib code for the third colouration pls.
                          * * * WRACK AND ROLL AND DEATH AND PAIN * * *
                                         * * * LET'S FEEL THE FEAR OF DEATH AGAIN * * *
              * * * WE'LL KILL AND SLAUGHTER, EAT THE SLAIN * * *
      * * * IN RAVAGING WE'LL ENTERTAIN * * *

    Ixion tells you, "// I don't think anyone else had a clue, amazing form."
  • local colourtable = {

    {"|cD22A2A","|cD2542A","|cD27E2A","|cD2A800","|cD2D200","|cA8D200","|cA8A800","|cA8A82A","|c7EA82A","|c54A82A","|c2AA82A","|c2A7E2A","|c2A7E54","|c007E54","|c007E7E","|c007EA8","|c0054A8","|c00547E","|c002A7E","|c2A2A7E","|c542A7E","|c7E2A7E"}, -- rainbow

    {"|c2A2A54","|c54547E","|c7E7EA8","|cA87EA8","|cD2A8A8","|cD2A8A8","|cD2A8A8","|cA87EA8","|c7E7EA8","|c547EA8","|c7E7EA8","|c54547E"}, -- dawn

    {"|cD22A2A","|cD2542A","|cD27E2A","|cD28C2A","|cD28C00","|cD2A800","|cD2C000","|cD2D200","|cD2C000","|cD2A800","|cD28C00","|cD28C2A","|cD27E2A","|cD2542A"}, -- fire

    {"|c00C4EE","|c1CC4EE","|c38C4EE","|c54C4EE","|c54A8EE","|c70A8EE","|c708CEE","|c548CEE","|c388CEE","|c1C8CEE","|c1CA8EE","|c00A8EE"}, -- water

    {"|c00A000","|c00B000","|c00C000","|c00D000","|c20D000","|c40D000","|c60D000","|c80D000","|c80C000","|c80B000","|c60B000","|c40B000","|c40A000","|c20A000"}, -- forest

    {"|c7E00D2","|c7E00BD","|c7E00A8","|c7E0093","|c7E007E","|c7E2A7E","|c7E447E","|c7E547E","|c7E5493","|c7E54A8","|c7E54BD","|c7E54D2","|c7E44D2","|c7E2AD2"}, -- this tastes like purple

    }


    Just replace the colour table in my original script with that.
  • Just a short snippet to pop a banner when you move from Zone to Zone

    currZone = CurrZone or {}

    currArea = currArea or ""

    currZone.check = function(event)

    if event == "gmcp.Room.Info" then

    if currArea ~= gmcp.Room.Info.area then

    currArea = gmcp.Room.Info.area

    cecho("<black:orange>****** CURRENT AREA IS NOW "..currArea.." ******\n")

    end

    end

    end

    registerAnonymousEventHandler("gmcp.Room.Info", "currZone.check")

  • edited August 2017
    This was originally some code for the towers of Hanoi type puzzles, but I edited this to delete the original post, as another recent post was deleted for showing a quest solution. Just figured I would do the same here.
  • Download a file & read it, updated this last night. The example is for Mudlet 3.0 previews because it uses an https:// link, but it'll work the same in 2.1 with an http:// link.

    -- create a function to parse the downloaded webpage and display a result
    function downloaded_file(_, filename)
      -- is the file that downloaded ours?
      if not filename:find("lusternia-who-count.html", 1, true) then return end
     
      -- read the contents of the webpage in
      local f, s, webpage = io.open(filename)
      if f then webpage = f:read("*a"); io.close(f) end
      -- delete the file on disk, don't clutter
      os.remove(filename)
     
      -- parse our downloaded file for the player count
      local pc = webpage:match([[Total: (%d+) players online]])
      display("Lusternia has "..tostring(pc).." players on right now.")
    end
     
    -- register our function to run on the event that something was downloaded
    registerAnonymousEventHandler("sysDownloadDone", "downloaded_file")
     
    -- download a list of fake users for a demo
    downloadFile(getMudletHomeDir().."/lusternia-who-count.html", "https://www.lusternia.com/game/who")
  • SylandraSylandra Join Queue for Mafia Games The Last Mafia Game
    Bless you. <3<3<3
    Daraius said:
    "Oh yeah, you're a naughty mayor, aren't you? Misfile that Form MA631-D. Comptroller Shevat's got a nice gemstone disc for you, but yer gonna have to beg for it."
  • You're welcome :)

    It could be that the timer is one or two minutes behind sometimes. Have not discovered why yet. Maybe, it gets confused by lag (my internet connection has been pretty bad lately).
  • edited March 2017
    Thyelleia said:
    You're welcome :)

    It could be that the timer is one or two minutes behind sometimes. Have not discovered why yet. Maybe, it gets confused by lag (my internet connection has been pretty bad lately).
    Think it's an issue with the way mudlet calculates timestamp differences, more than anything. Happens with MMF sometimes, too, where it says you took like 60 seconds to recover balance, because the minute/hour/day rolled over.
    Email:        el.ni93@hotmail.com
    Discord:    Rey#1460
  • edited June 2017
    To generate a line break for clothing in descriptions:

    Perl Regex Pattern: 
    S?[Hh]e is a\s.+[.?!]{1}\s(S?[Hh]e) is wearing.+\.$

    Code:
    replaceWildcard(2, "\n".. matches[2])

    Output:
    She is a fierce rapscallion dracnari and looks fresh from a bender. Swollen, 
    purple bags under her eyes contrast her sunburst scales. Over six feet, her 
    stature is far from petite with a fat tail and hips, a healthy belly exaggerated 
    by a flat chest, and strong hands. Chirbi appears more "oid" than human having a 
    salamander's wide lips and the nails of a beast. Her large head is earless with 
    black globes for eyes, a flat nose and large nostrils. 
    She is wearing 7 wooden rings, practical brown leather gloves, a polished bone 
    pendant, slovenly, leather robes of umber with a high collar, a pair of rose-
    coloured spectacles, knee-high, cuffed brown leather boots, a sturdy brown 
    backpack, a clover-etched jade brooch and the Golden Belt of the Enlightened.

    edit: I was unsure if you could end a description with any terminal punctuation, so that's why the special character class of [.?!]
  • edited July 2017
    Kind of Gaudi specific and in the format of a clhelp scroll, but it's easily adaptable for other portal chamber'y or transplanar'y things. Let me know if you'd like help!

    edit: Originally, I didn't provide any means of removing rooms that don't allow for use of the belt, or locking off entire areas. I've updated that now.

    Here's an easy way to make use of your Belt of the Enlightened with GMCP, Mudlet's Mapper, and the IRE Mapping Script in under 5 minutes. First, we'll map the chamber and second, we'll create the script. Once you're up and running, the mapper will begin to check all rooms to see if they're outdoors, and if so remember them as a location where you can use your belt. If you've not yet enabled GMCP, it can be turned on by clicking 'Settings' and selecting 'Enable GMCP' on the first screen, second from the bottom.

    First, touch your belt to teleport to the chamber. To map the room, enter the following commands in order from Mudlet's main command line:
    mc on<br>rlc v19627 0 0 0<br>area add Limbo<br>room area Limbo<br>rlk 19343 se one<br>rlk 19514 nw one<br>rlk 19222 up one<br>rlk 19666 sw one<br>rlk 19527 ne one<br>rlk 11401 down one<br>rlk 19693 north one<br>mc off

    Second, we setup the script! We'll create a script group, I called mine 'MapHax'. I didn't place it inside of 'mudlet-mapper' to avoid any issues when the IRE Mapping Script updates. Open up a plain text editor (Notepad, Gedit, etc.) and save a blank file inside your mudlet home directory called 'maphax'. If you don't know where your mudlet home directory is, from the command line run 'lua echo(getMudletHomeDir())'. Inside the group, paste the following script:

    maphaxloc = getMudletHomeDir().. "/maphax"<br>maphax = maphax or {beltlocked = {}}<br><br>function MapHax()<br>&nbsp; loadMapHax()<br>end<br><br>function loadMapHax()<br>&nbsp; if io.exists(maphaxloc) then table.load(maphaxloc, maphax) end<br>end<br><br>function saveMapHax()<br>&nbsp; if io.exists(maphaxloc) then table.save(maphaxloc, maphax) end<br>end
    Inside that group, we'll create a script item called 'The Belt of the Enlightened'. In the body of the script, copy and paste the following:    
    registerAnonymousEventHandler("gmcp.Room.Info", "checkBelt")
    
    function checkBelt()
      local area = gmcp.Room.Info.area
    	local outdoors = gmcp.Room.Info.details[2]
      if not table.contains(maphax.beltlocked, area) and outdoors == "outdoors" then
    		local num = gmcp.Room.Info.num
        if not table.contains(getSpecialExits(num), "TOUCH ENLIGHTENED") then
          addSpecialExit(num, 19627, "TOUCH ENLIGHTENED")
      		echo("\n(Map Hax): Added use of the Golden Belt of the Enlightened from v".. num..".")
        end
      end
    end
    
    function beltLock(num, area)
      if not table.contains(maphax.beltlocked) then
    	  table.insert(maphax.beltlocked, area)
    		echo("\n(MapHax): Can't use the Golden Belt of the Enlightened, locking the area.")
    	end
    	
    	for k, v in pairs(getAreaRooms(getRoomArea(num))) do
    	  if table.contains(getSpecialExits(v), "TOUCH ENLIGHTENED") then
          removeSpecialExit(v, "TOUCH ENLIGHTENED")
        end
    	end
    end

    For ease of copy+paste and sharing, this is also available via pastebin: https://pastebin.com/m663YbL8
  • edited August 2017
    I wrote a thingie. It  can be used in place of ansi2decho() for coloring things from gmcp comms, except it also highlights peoples names using their NDB colors


    function ansindb(text)
    local text = ansi2decho(text)
    color = string.match(text,"^<?r?>?<%d+,%d+,%d+:%d-,?%d-,?%d->")
    local background = color:match(":.->") or ":>"
    local highlighted = {}
    for _, name in pairs(ndb.findnames(text)or {}) do
    if not table.contains(highlighted,name) then
    if ndb.getcolor(name)~="" then
    text = text:gsub(name,string.format("<r><%d,%d,%d",unpack(color_table[string.sub(ndb.getcolor(name),2,-2)]))..background..name..color)
    end
    table.insert(highlighted,name)
    end
    end
    return text
    end
  • Kali said:
    I wrote a thingie. It  can be used in place of ansi2decho() for coloring things from gmcp comms, except it also highlights peoples names using their NDB colors


    function ansindb(text)
    local text = ansi2decho(text)
    color = string.match(text,"^<?r?>?<%d+,%d+,%d+:%d-,?%d-,?%d->")
    local background = color:match(":.->") or ":>"
    local highlighted = {}
    for _, name in pairs(ndb.findnames(text)or {}) do
    if not table.contains(highlighted,name) then
    text = text:gsub(name,string.format("<r><%d,%d,%d",unpack(color_table[string.sub(ndb.getcolor(name),2,-2)]))..background..name..color)
    table.insert(highlighted,name)
    end
    end
    return text
    end
    Ooo, thanks. Now to see if I can get it to work with the chat box in Reys GUI.
  • Moderator Note: I have deleted the post that gave a coding-based solution to quest mazes. It is fine to post hints regarding quests on the forums, but we prefer people to not post full solutions - this script falls into the latter category.
  • Czixi said:
    Moderator Note: I have deleted the post that gave a coding-based solution to quest mazes. It is fine to post hints regarding quests on the forums, but we prefer people to not post full solutions - this script falls into the latter category.
    Administrator Note: This will also be fixed in the next game patch.
    Forum Avatar drawn by our lovely Isune.
  • updateAddPlayer = function ()
    	if ndb.isglom(gmcp.Room.AddPlayer.name) then
    		send("infect " .. gmcp.Room.AddPlayer.name)
    	end
    end
    registerAnonymousEventHandler("gmcp.Room.AddPlayer", "updateAddPlayer")

    Mostly for fighting fire with fire. Just put this in a script.

    beep
  • </code><pre class="CodeBlock"><code><code>local warningThings={<br>healing=true,<br>bromides=true,<br>mana=true,<br>dust=true,<br>restorativeice=true,<br>steam=true,<br>sparkleberry=true,<br>}<br>local threshold = 100<br>function riftWarning()<br>if warningThings[gmcp.IRE.Rift.Change.name] and tonumber(gmcp.IRE.Rift.Change.amount)<threshold then<br>cecho("<red>"..gmcp.IRE.Rift.Change.amount.." "..gmcp.IRE.Rift.Change.name.." left!")<br>end<br>end<br>registerAnonymousEventHandler("gmcp.IRE.Rift.Change","riftWarning")

    Simple script that just echos when you're running low on certain things. Easy enough to add more things to look for, as long as you have the name for it used by gmcp.IRE.Rift

  • edited October 2017
    Alias       Command
    -----------------------------------------------------------------------------
    SETALIAS FNDCHEFMARKET PATH TRACK 421
    SETALIAS FNDHLLFRAE  PATH TRACK 13725
    SETALIAS FNDHSTABLE  PATH TRACK 19924
    SETALIAS FNDADALGS   PATH TRACK 25391                      [the composer, for bard empowerment]
    SETALIAS FNDVFLAME  PATH TRACK 19526
    SETALIAS FNDETHERFREST PATH TRACK 4932 || enter archway      [etherseren entrance from maeve's court]
    SETALIAS FNDTRKA PATH TRACK 344
    SETALIAS FNDDELL PATH TRACK 7526                            [caominhe dell]
    SETALIAS FNDBARNA PATH TRACK 542
    SETALIAS FNDKUL PATH TRACK 310
    SETALIAS FNDTLBRLLA  PATH TRACK 9529
    SETALIAS FND3JUNCTN PATH TRACK 294
    SETALIAS FNDRSADRL  PATH TRACK 510
    SETALIAS FNDLRED PATH TRACK v6360
    SETALIAS FNDPHLSH    PATH TRACK 478
    SETALIAS FNDAURRE    PATH TRACK 446
    SETALIAS FNDYRCH     PATH TRACK 413
    SETALIAS FNDLWLANDS  PATH TRACK 2592              [plex....something lowlands. up in the mountains]
    SETALIAS FNDJRC      PATH TRACK 391
    SETALIAS FNDCAFAN    PATH TRACK 352
    SETALIAS FNDAELCH    PATH TRACK 363
    SETALIAS FNDTHEARCHWAY PATH TRACK 19626      [Air plane archway to ethereal plane]
    SETALIAS FNDTHEMATRX PATH TRACK 19765           [for hallifaxians: air plane matrix]
    SETALIAS FNDLARS     PATH TRACK 18971
    SETALIAS FNDRC       PATH TRACK 1756                   [roc caverns]
    SETALIAS FNDCAY      PATH TRACK 20693                [cay of clodashi.]
    SETALIAS FNDSNWVALLEY PATH TRACK 2106
    SETALIAS FNDASYLUM   PATH TRACK 2072               [Ixii'a asylum]
    SETALIAS FNDPERRE    PATH TRACK 2622                  [Pierre: lydia windwhispers BF]
    SETALIAS FNDZAKA     PATH TRACK 2665                  [Mt Zoaka entrance]
    SETALIAS FNDSHALLACH PATH TRACK 6258
    SETALIAS FNDPRESD    PATH TRACK 2076                [presidio of the damned]
    SETALIAS FNDMANTCRE  PATH TRACK 1909
    SETALIAS FNDCAVERNS  PATH TRACK 1913               [nagaradja caverns]
    SETALIAS FNDBAY      PATH TRACK 3125                  [Bay of bondero]
    SETALIAS FNDFPRTAL   PATH TRACK 273
    SETALIAS FNDDRAN     PATH TRACK 3154                 [Taerin's drain: access to undervault + crystal meadows]
    SETALIAS FNDVSTAGE   PATH TRACK 25391
    SETALIAS FNDSCRPNCAVE PATH TRACK 15996           [desert, scorpion flies]
    SETALIAS FNDWAYFARE  PATH TRACK 14763
    SETALIAS FNDFEYRANT  PATH TRACK 2056
    SETALIAS FNDCLARRAMRE PATH TRACK 16530
    SETALIAS FNDLBLUE    PATH TRACK v6361
    SETALIAS FNDGGATE   PATH TRACK 11231                 [gaudiguch: to the mountains]
    SETALIAS FNDCHANCEL  PATH TRACK 2646                [klangatch chancel]
    SETALIAS FNDGSTAIR  PATH TRACK 11215                  [gaudiguch: twisted stairs- to the road]

    this uses lusternia's inbuilt alias system. copy & paste into the mudlet system. bookmarks useful locations on prime.


  • There's also the room marks system for the mudlet mapper, which lets you associate a string with a room and use the string to walk to it.
    ROOM MARK <room number> <mark name> to create a mark
    ROOM MARKS to list the marks
    ROOM UNMARK <mark name> to delete a mark.
    GOTO <MARK NAME> [sprint|glide|etc] to go to a mark, the same way you'd path to an area or room number.

  • A thing for sporelist!

  • edited July 2018
    Mudlet Lua script for searching back multiple weaves of a log.

    Currently does not do ('more'), on its own, so assuming either results are within pagelength or you do 'more' automatically.

    Edit: updated with suggestion from @Aeldra to suppress the big string of ';' separated commands with false flag. Thanks!

    -- ex. search back in org log for mentions or notes by Barrin back 12 weaves to today, inclusive<br>searchlog serenwilde 12 barrin<br>-- ex. search back in power for fae gathered (because First of the Crones, First of the Maidens, etc.)
    searchlog power first
    -- Alias name: searchlog
    -- Pattern:&nbsp;^searchlog (\w+)\s?(\d+)? (\w+)$<br><p>local searchLog
    local backTo
    local searchString = matches[4]
    local query
    
    if matches[2] == "power" or matches[2] == "powerlog" then
    	searchLog = "powerlog"
    else
    	searchLog = "readlog "..matches[2]
    end 
    
    if matches[3] == "" then
    	backTo = 30
    else
    	backTo = matches[3]
    end
    
    query = searchLog.." 0 "..backTo.." "..searchString
    backTo = backTo - 1
    
    local i
    for i = backTo,0,-1 do
    	query = query.."; "..searchLog.." 0 "..i.." "..searchString
    end
    
    send("config pagelength 250")
    send(query, false) -- flag false to <span>suppress the big string of ';' separated commands</span>
    send("config pagelength 30") -- or back to your usual pagelength, check with CONFIG<br></p>

    Active: Monday, Thursday, Friday, Saturday EST

    Avatar made through Picrew
  • Thank you for posting this, @Xiran.
    I was planning to make something similar but now I don't have to.
  • If anyone else is still using the old M&MF influencing thing, and is curious to know which denizens in the room you've influenced already, try putting this in a script/alias/trigger/whatever:

    function checkInfluenced(bool)
    	local long = bool or false
    	for k, v in pairs(mmi.roomnpcs) do 
    		if v.influencable and v.influenced then
    			if long then cecho("<PaleGreen>"..v.longname.."\n") else cecho("<PaleGreen>X") end
    		elseif v.influencable and not v.influenced then
    			if long then cecho("<antique_white>"..v.longname.."\n") else cecho("<antique_white>.") end
    		end	
    	end
    end
    In this quick little example I clumsily hacked together, you can choose whether you want to see the names of the denizens in the room by passing in "true" - false, or just nothing, will give you the short version.

    Long:


    Short:

Sign In or Register to comment.