Lua Scripts

edited October 2012 in Mechanic's Corner
It's high time somebody started a thread for this, so here goes.

I'll start the ball rolling with a small function that I was asked to write. Given a sentence as a string, the function will return any palindromes found in the string.

function findpalindromes(array)

   local words = {}

   for word in string.gmatch(array, "%a+") do

      if word == string.reverse(word) then

         table.insert(words, word)

      end

   end

   return words

end


I did try to put it in code tags, but it seems clicking the icon has absolutely no effect and the usual [code] and [/code] does not apply here. Meh. Silly new forums.

Comments

  • You can click on the source button and then add in <CODE> </CODE> around your stuff!

    Yaaay, lua thread. :)
  • edited November 2012
    Here we go. I posted this on the old forums, but it's been improved since then. This is for Mudlet only, I am afraid, but enjoy some timed warning labels.

    image

    To use, simply call the function with the text you require from within a script or trigger, i.e.

    visWarn("Hi! I am a test label.")

    Enjoy :)

  • Here is my cleaner linked vials script for Mudlet:  cleaner linked vials.


    This formats your linked vials to take up less horizontal space as well as look much neater when viewing them via "info inventory". I use this on a wrapwidth of 80. It will cost you one additional line per linked vial.

  • I updated my cleaner linked vials. It will handle more cases now (such as quicksilver), and keeps it the display consistent (removing a/an). To keep the links more visible I added a hyphen before each one, but if you don't like it you can easily change it in the code, just make sure you do both the gate and the chain.


    Here is the new link: cleaner linked vials v2 .


    Feel free to message me in the game or over the forums with whatever line happens to break display!

  • Nice one. Amber beer gets cut off as mber beer though
  • Here's a script that I've got, I did not make it (I think it was made originally for MUSHclient), but it seems to be missing from the forums now, so reposting for others. It splits what people are wearing - an item per line.

  • FayFay
    edited December 2012

    Vadi said:
    Nice one. Amber beer gets cut off as mber beer though

    Fixed! Forced it to match as a whole word. I struggle a bit with regular expressions, but I usually get what I need :)


    New link: cleaner linked vials v3.


    The limited edit time makes for this to be kind of messy, I think.

  • Just some basic right-click menus for looking at wares. Nothing too special, but haven't seen anything up and just finished doing my first go at it for personal use, figured I'd post it.

  • Just posted this to the mudlet forums, thought others here may also find it useful.

  • FayFay
    edited February 2013

    I've updated my cleaner linked vials! It now captures up to 6 lines when a link has been detected (for those who are using a fesix bandolier), and I improved trigger to be easier on the client for those already have a lot going.


    Cleaner linked vials v4
  • NeosNeos The Subtle Griefer
    edited September 2013
    Quick script I wrote today, stops your command if you're trying to move in a direction that isn't available in the room. Need to add the sysDataSendRequest event to get it to work and of course name the script noMove.

    function noMove(_, direction)
    local directions, exits, move

    move = {
            n = "n",
            ne = "ne",
            e = "e",
            se = "se",
            s = "s",
            sw = "sw",
            w = "w",
            nw = "nw",
            u = "u",
            d = "d",
            ["in"] = "in",
            out = "out",
            north = "n",
            northeast = "ne",
            east = "e",
            southeast = "se",
            south = "s",
            southwest = "sw",
            west = "w",
            northwest = "nw",
            up = "u",
            down = "d",
    }

    directions = {
            "n",
            "north",
            "ne",
            "northeast",
            "e",
            "east",
            "se",
            "southeast",
            "s",
            "south",
            "sw",
            "southwest",
            "w",
            "west",
            "nw",
            "northwest",
            "u",
            "up",
            "d",
            "down",
            "in",
            "out"
    }

    exits = gmcp.Room.Info.exits

    local go = move[direction]

    if table.contains(directions, direction:lower()) and not exits[go] then
        cecho("\n<red>Can't go that way dummy. Try again!")
        denyCurrentSend()
    end

    end

    Could probably have been done better, but I'm sick, so whatever.
    Love gaming? Love gaming stuff? Sign up for Lootcrate and get awesome gaming items. Accompanying video.

     Signature!


    Celina said:
    You can't really same the same, can you?
    Zvoltz said:
    "The Panthron"
  • KaimanahiKaimanahi The One True Queen
    Neos said:
    Quick script I wrote today, stops your command if you're trying to move in a direction that isn't available in the room. Need to add the sysDataSendRequest event to get it to work and of course name the script noMove.

    ...

    Could probably have been done better, but I'm sick, so whatever.
    I think that this will cause you problems in places with hidden exits (e.g., room 5075 on Cancer) and in other cases.
    image
  • NeosNeos The Subtle Griefer
    edited September 2013
    Yes, I realized that on Celestia today >.>
    Will try and add in a fix when I can.

    Edit: Ok, fixed.

    function noMove(_, direction)

    local directions, exits, move


    move = {

    n = "north",

    ne = "northeast",

    e = "east",

    se = "southeast",

    s = "south",

    sw = "southwest",

    w = "west",

    nw = "northwest",

    u = "up",

    d = "down",

    ["in"] = "in",

    out = "out",

    north = "north",

    northeast = "northeast",

    east = "east",

    southeast = "southeast",

    south = "south",

    southwest = "southwest",

    west = "west",

    northwest = "northwest",

    up = "up",

    down = "down",

    }


    directions = {

    "n",

    "north",

    "ne",

    "northeast",

    "e",

    "east",

    "se",

    "southeast",

    "s",

    "south",

    "sw",

    "southwest",

    "w",

    "west",

    "nw",

    "northwest",

    "u",

    "up",

    "d",

    "down",

    "in",

    "out"

    }


    exits = getRoomExits(gmcp.Room.Info.num)

    local go = move[direction]

    if table.contains(directions, direction:lower()) and not exits[go] then

    cecho("\n<red>Can't go that way dummy. Try again!")

    denyCurrentSend()

    end


    end


    Bluh, current version errors in manses unless you've mapped them and trying to fix it will take a bit. Anyone wanting to take a shot at it can.
    Love gaming? Love gaming stuff? Sign up for Lootcrate and get awesome gaming items. Accompanying video.

     Signature!


    Celina said:
    You can't really same the same, can you?
    Zvoltz said:
    "The Panthron"
  • Won't it also cause problems if you stack movement commands? Why do you want it anyway?
  • edited October 2013
    I was doing some alchemy scripts and saw Parua's request in that other thread, so I made it a bit more user friendly and here you go.

    EDIT: NVM Got it now. Nothing to see here in the edit. <___<
  • edited February 2014
     

  • edited October 2013
    Iasmos said:
    Mudlet XML is the most verbose, least user-friendly XML I've ever seen.
    :-?
    I think a bigger question is why are there aetherpiloting bits (among other things) in there.
  • Ayisdra said:
    Iasmos said:
    Mudlet XML is the most verbose, least user-friendly XML I've ever seen.
    :-?
    I think a bigger question is why are there aetherpiloting bits (among other things) in there.
    I may have completely forgotten to check the keys and buttons tab while preparing that and forgotten to remove some thing, whoops. Probably because I set some keybinds up for piloting/sprinting once ages ago and have never looked at that tab again.
  • edited February 2014
    Here's a simple script for solving the unknown leg of a right-angle triangle if you have the hypotenuse and the other leg. Useful for a certain area if you're like me and too lazy to break out the calculator:

    Pattern:

    ^solve (\d+) (\d+)$

    Goes in the script box:

    if tonumber(matches[2]) < tonumber(matches[3]) then

    hypotenuse = tonumber(matches[3])

    leg = tonumber(matches[2])

    else

    hypotenuse = tonumber(matches[2])

    leg = tonumber(matches[3])

    end


    local sqrt = hypotenuse^2 - leg^2


    local n = math.sqrt(sqrt)


    echo("\n"..n)


    Instructions:

    To use it, simply type solve 11 61 or solve 61 11 - both should give an answer of 60.
  • ZouviqilZouviqil Queen of Uberjerkiness
    More of a Mudlet script than a lua one, but useful nonetheless.

    Let's say you're in a ton of clans, right? And you keep messing up CLT8 or CLT9.

    Type CLANS to see what clans you have and their number and their shortname. You'll want to likely set your clan's alias to the shortname, unless the shortname is actually long.

    Pattern: ^ooc (.*)$
    Code: send("clan ooc tell " .. matches[2])
    How you use it: ooc Hey guys, how are you today?
    What's sent to the game: clan ooc tell Hey guys, how are you today?
    What you see: (OOC): You say, "Hey guys, how are you today?"
    What others in that clan see: (OOC): Zouviqil says, "Hey guys, how are you today?"

    Easy and short.
  • Wondering if anybody can assist. I am trying to simplify Brewing for a Brewmeister. Specifically for White tea.

    Using Mudlet and M&MF.

    I want to be able to add 10 whitetea, amalgamate whitetea, and once mm.bals.equilibrium is reached, get whitetea from alembic. My thoughts are to use this as an alias, or loop, so that I am not constantly typing all three commands, but rather running a script to hand them for me, as long as I have the commodities.

    Has anybody created such a looper? I have been toying with ideas, but im not really getting any closer, so thought id ask. I am relearning LUA again, so falling short on what I used to know.
    image
  • AeldraAeldra , using cake powered flight
    Zilias said:
    Wondering if anybody can assist. I am trying to simplify Brewing for a Brewmeister. Specifically for White tea.

    Using Mudlet and M&MF.

    I want to be able to add 10 whitetea, amalgamate whitetea, and once mm.bals.equilibrium is reached, get whitetea from alembic. My thoughts are to use this as an alias, or loop, so that I am not constantly typing all three commands, but rather running a script to hand them for me, as long as I have the commodities.

    Has anybody created such a looper? I have been toying with ideas, but im not really getting any closer, so thought id ask. I am relearning LUA again, so falling short on what I used to know.
    If you do possess access to the 'stratagems' skills in the combat tree, you can simply do the following:

    sm add outr 10 whitetea|add 10 whitetea|amalgamate whitetea
    sm add get 10 whitetea from alembic

    Otherwise, there is, if you read up on m&mf's documentation (http://m-mf.github.io/m-mf/) a way to use m&mf's queuing system using mm.doadd, something like this maybe:

    mm.doaddfree("outr 10 whitetea")
    mm.doaddfree("add 10 whitetea)
    mm.doadd("amalgamate whitetea")
    mm.doadd("get 10 whitetea from alembic")

    Avatar / Picture done by the lovely Gurashi.
  • If you're making whitetea, you're going to need rawtea to amalgamate. From there, it's a simple command to make the actual drink white tea. Just need a bottle/keg and the ingredients (one of which will be whitetea, of course).

    image
Sign In or Register to comment.