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

2»

Comments

  • ReylariReylari Member Posts: 367 Fabled
    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 Member Posts: 2,543 Transcendent
    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."
  • FalaeronFalaeron Jolteon Member Posts: 1,650 Transcendent
    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)
    local str = ""
    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
    }
    local colours = {}

    if mode > #colourtable then
    colours = colourtable[1]
    else
    colours = colourtable[mode]
    end

    local i = math.random(#colours)

    for char in text:gmatch(".") do
    if char == " " then
    str = str .. char
    else
    str = str .. colours[i] .. char
    if i == #colours then i = 0 end
    i = i + 1
    end
    end

    return hecho(str)
    end
    Then you can call it using:
    rainbow("Blah blah blah", 1)

    1 is for rainbow, 2 is for dawn.
  • TremulaTremula Banished Quasiroyal Member Posts: 2,543 Transcendent
    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."
  • FalaeronFalaeron Jolteon Member Posts: 1,650 Transcendent
    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 Member Posts: 2,543 Transcendent
    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 Member Posts: 2,543 Transcendent
    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."
  • FalaeronFalaeron Jolteon Member Posts: 1,650 Transcendent
    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.
  • TambadorTambador Member Posts: 48 Apprentice
    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")

  • FoehnFoehn Member Posts: 67 Capable
    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.
    Post edited by Foehn on
  • VadiVadi Member Posts: 256 Gifted
    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 Friend of Dog Member Posts: 4,298 Transcendent
    Bless you. <3 <3 <3
    Fyler said:
    Sylandra has a very signature (and somewhat twisted) sense of humor
  • ThyelleiaThyelleia Member Posts: 255 Fabled
    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).
  • ReylariReylari Member Posts: 367 Fabled
    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
  • ChirbiChirbi Member Posts: 148 Capable
    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 [.?!]
  • ChirbiChirbi Member Posts: 148 Capable
    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
    rlc v19627 0 0 0
    area add Limbo
    room area Limbo
    rlk 19343 se one
    rlk 19514 nw one
    rlk 19222 up one
    rlk 19666 sw one
    rlk 19527 ne one
    rlk 11401 down one
    rlk 19693 north one
    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"
    maphax = maphax or {beltlocked = {}}

    function MapHax()
      loadMapHax()
    end

    function loadMapHax()
      if io.exists(maphaxloc) then table.load(maphaxloc, maphax) end
    end

    function saveMapHax()
      if io.exists(maphaxloc) then table.save(maphaxloc, maphax) end
    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
    Post edited by Chirbi on
  • KaliKali Member Posts: 46 Capable
    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
    Post edited by Kali on
  • KerithKerith Member Posts: 267 Gifted
    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.
  • CzixiCzixi Member, Gods Posts: 104 Divine
    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.
  • IanirIanir Administrator, Moderator Posts: 472 Creator
    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.
  • YehnYehn Member Posts: 282 Master
    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
  • KaliKali Member Posts: 46 Capable
    local warningThings={
    healing=true,
    bromides=true,
    mana=true,
    dust=true,
    restorativeice=true,
    steam=true,
    sparkleberry=true,
    }
    local threshold = 100
    function riftWarning()
    if warningThings[gmcp.IRE.Rift.Change.name] and tonumber(gmcp.IRE.Rift.Change.amount)<threshold then
    cecho("<red>"..gmcp.IRE.Rift.Change.amount.." "..gmcp.IRE.Rift.Change.name.." left!")
    end
    end
    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

  • OrdassaOrdassa Member Posts: 331 Master
    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.


    Post edited by Ordassa on
  • KaliKali Member Posts: 46 Capable
    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.

2»
Sign In or Register to comment.