Mudlet questions & answers!

1679111214

Comments

  • It's a bit slower than other ways (not noticably slower for a few instances in a system) but all in all, it works, so use it.
    Achieved dragon on the 13th of Aeguary, 634 - aged 21 and 1 month and 21 days.

    Elder dragon on the 6th of Chronos 635 - aged 22 and 8 months and 14 days.
  • Yes, expandAlias is something you shouldn't use - use the function directly if you can, or if it's stuff you yourself are creating - create a function and call that in many places instead of the alias.
  • Cathy said:

    It's a bit slower than other ways (not noticably slower for a few instances in a system) but all in all, it works, so use it.

    It's discouraged for a number of reasons aside from just speed. For example, it can alter the matches table for the alias or trigger you call it from, which can produce bugs that are tricky to track down, and its behaviour (and therefore the behaviour of the script it's called from) can change depending on what other aliases you have defined. As Vadi says, better to just define a single function and call out in both places.
  • Halp. :(

    How do I do things like:

    If (variable) is not equal to (whatever) then (do stuff)

    and

    If (variable) is equal to (whatever) then (do stuff)

    Also, is there a way to put a variable in a trigger line? Like, in zmud I could trigger off of "@target jabs you."

  • image
    If you need me, you can find me sporadically on the Achaea Discord as Yae. 
    Do not DM on forums unless you're ok with waiting a couple months!
  • the answer to your second question is no
  • Technically you could do it with tempTriggers, deleting and recreating them everytime you used your targeting alias. No way to do it through the GUI that I know of though
    image
  • edited November 2013
    Lua function: return line:find(variable, 1, true) and true or false

    Essentially checks for the presence of the value of variable in the current line, and returns true or false accordingly. You'd need to use an AND trigger, so that it checks for both the perl regex matching and that check returning true.
  • Antonius said:
    Lua function: return line:find(variable, 1, true) and true or false

    Essentially checks for the presence of the value of variable in the current line, and returns true or false accordingly. You'd need to use an AND trigger, so that it checks for both the perl regex matching and that check returning true.
    I believe the "and true or false" there is redundant, unless I'm missing something about how the truth value of the condition is evaluated for lua triggers.
  • edited November 2013
    EDIT: ignore
  • Eld said:
    Antonius said:
    Lua function: return line:find(variable, 1, true) and true or false

    Essentially checks for the presence of the value of variable in the current line, and returns true or false accordingly. You'd need to use an AND trigger, so that it checks for both the perl regex matching and that check returning true.
    I believe the "and true or false" there is redundant, unless I'm missing something about how the truth value of the condition is evaluated for lua triggers.
    Pretty sure the "and true or false" is needed. find() returns either nil or a set of numbers, and I think the lua condition triggers always want a straight boolean.
  • Iocun said:
    Eld said:
    Antonius said:
    Lua function: return line:find(variable, 1, true) and true or false

    Essentially checks for the presence of the value of variable in the current line, and returns true or false accordingly. You'd need to use an AND trigger, so that it checks for both the perl regex matching and that check returning true.
    I believe the "and true or false" there is redundant, unless I'm missing something about how the truth value of the condition is evaluated for lua triggers.
    Pretty sure the "and true or false" is needed. find() returns either nil or a set of numbers, and I think the lua condition triggers always want a straight boolean.
    That would be pretty strange behaviour, imo. I just loaded up mudlet and made a lua trigger with the condition "return 1" and an echo, and it echos on every line. "return nil" as expected, does not. 
  • Seems I was mistaken then!
  • Eld said:
    Antonius said:
    Lua function: return line:find(variable, 1, true) and true or false

    Essentially checks for the presence of the value of variable in the current line, and returns true or false accordingly. You'd need to use an AND trigger, so that it checks for both the perl regex matching and that check returning true.
    I believe the "and true or false" there is redundant, unless I'm missing something about how the truth value of the condition is evaluated for lua triggers.
    Good to know. I stole that from somewhere else (svo maybe?) ages ago back when I first started using Mudlet and never really considered whether it was all necessary (I had to dig through my triggers to find the one that uses it because it hasn't been touched in probably a year and a half).
  • Mudlet used to require that, which is why Iocun thought that way (and Svo code still uses it), but it has been improved to use Lua's understanding of true and false in recent releases.
  • KenwayKenway San Francisco
    SOMEONE PLEASE HELP ME I'VE BEEN TRYING TO FIX THIS FOREVER AND NOTHING HELPS I'M GOING TO CUT OUT KENWAY'S VOCAL CHORDS. OR WALK INTO MHALDOR AND GIVE SOMEONE A HUG, EFFECTIVELY RESULTING IN THE SAME THING.

    image

    - Limb Counter - Fracture Relapsing -
    "Honestly, I just love that it counts limbs." - Mizik Corten
  • you have a duplicate trigger somewhere?


    image
  • KenwayKenway San Francisco
    Anaidiana said:
    you have a duplicate trigger somewhere?
    That's what the right part of the screencap is about. That's the only trigger that sends "ok" that exists

    - Limb Counter - Fracture Relapsing -
    "Honestly, I just love that it counts limbs." - Mizik Corten
  • edited November 2013
    That's not the only trigger that sends "ok"... that's the only trigger that does exactly send("ok"). You could have another that does send ("ok") or send('ok') or send "ok" or send"ok" and many more possibilities and permutations thereof...

    btw the debug view will tell you exactly which triggers match on a line.
  • So all text content in Mudlet between < and > and everything after < gets removed, so I get:

    3697h, 4327m, 16200e, 18570w cexkdb-41.0%- 13:50:14:613tell jozlyn // testing <testing> .
    You tell Troublemaking Walnut, Jozlyn Shiva Van Helsing, "// testing  ."

    and

    Syntax: STAFFSTRIKE  WITH  [limb]

    Instead of I assume STAFFSTRIKE <target> WITH [limb]

    I disabled timers and triggers, so it doesn't seem to be related to the system. Any idea what to do?
    image
  • edited December 2013
    Hrm, doesn't happen for me. I assume you disabled all processing (with the bomb icon), so aliases were disabled too.

    My main guess is that it has something with MXP processing, i.e. Mudlet thinking that what you put in <> to be MXP tags and hiding them. I recommend using CONFIG MXP OFF in-game, and unchecking the checkbox for "Force MXP negotiation off" under your Mudlet Settings/Special Options.

    Make sure to quit your profile and then restart it from scratch after this change, or it won't come into effect.
  • Either turn MXP on in the game or force-disable MXP in Mudlet's settings. Achaea is not very good about its protocol negotiation and is implying to Mudlet that MXP is on, which necessitates doing special things with <>'s.
  • I currently have a temp timer cecho to track when I need to reapply hamstring.  However, when you strike hamstring on a hamstringed target, the duration resets.  I want my timer to mimic this.

    What I'm saying is if I hit hamstring, then hit it again right afterward, I will an echo pop up 5.5 seconds after the first hamstring and another 5.5 seconds after the second hamstring.  I don't want that to happen.  I only want the echo that happens 5.5 seconds after the second hamstring.

    :(
    [2:41:24 AM] Kenway: I bet you smell like evergreen trees and you could wrestle boreal mammals but they'd rather just cuddle you
  • EldEld
    edited December 2013

    @Kuy:


    if hamstringwarning then killTimer(hamstringwarning) end

    hamstringwarning = tempTimer(7,string.format([[pv.echo("\n%s hamstring wearing off in 2 seconds!")]],multimatches[2][2]))


  • yay thanks!
    [2:41:24 AM] Kenway: I bet you smell like evergreen trees and you could wrestle boreal mammals but they'd rather just cuddle you
  • KuyKuy
    edited December 2013
    fixed
    [2:41:24 AM] Kenway: I bet you smell like evergreen trees and you could wrestle boreal mammals but they'd rather just cuddle you
  • Oh, forgot to note that the multimatches entry may well need to be changed to match your trigger.
  • ^hd(c|x|k|d|de|p|e|a)(c|x|k|d|de|p|e|a)$


    if matches[2] == "x" then

    local venomone = "xentio"

    elseif matches[2] == "k" then

    local venomone = "kalmia"

    elseif matches[2] == "d" then

    local venomone = "darkshade"

    elseif matches[2] == "de" then

    local venomone = "delphinium"

    elseif matches[2] == "p" then

    local venomone = "prefarar"

    elseif matches[2] == "e" then

    local venomone = "euphorbia"

    elseif matches[2] == "a" then

    local venomone = "aconite"

    elseif matches[2] == "c" then

    local venomone = "curare"

    end


    if matches[3] == "x" then

    local venomtwo = "xentio"

    elseif matches[3] == "k" then

    local venomtwo = "kalmia"

    elseif matches[3] == "d" then

    local venomtwo = "darkshade"

    elseif matches[3] == "de" then

    local venomtwo = "delphinium"

    elseif matches[3] == "p" then

    local venomtwo = "prefarar"

    elseif matches[3] == "e" then

    local venomtwo = "euphorbia"

    elseif matches[3] == "a" then

    local venomtwo = "aconite"

    elseif matches[3] == "c" then

    local venomtwo = "curare"

    end


    send("stand", false)

    send("dsl " .. target .. " head " .. venomone .. " " .. venomtwo, false)



    Why won't this work? :(


    Also, if it's because the things here don't work the way I think they do, any help trying to get it to be workable?

    [2:41:24 AM] Kenway: I bet you smell like evergreen trees and you could wrestle boreal mammals but they'd rather just cuddle you
  • EldEld
    edited December 2013
    Kuy said:

    ^hd(c|x|k|d|de|p|e|a)(c|x|k|d|de|p|e|a)$


    if matches[2] == "x" then

    local venomone = "xentio"

    elseif matches[2] == "k" then

    local venomone = "kalmia"

    elseif matches[2] == "d" then

    local venomone = "darkshade"

    elseif matches[2] == "de" then

    local venomone = "delphinium"

    elseif matches[2] == "p" then

    local venomone = "prefarar"

    elseif matches[2] == "e" then

    local venomone = "euphorbia"

    elseif matches[2] == "a" then

    local venomone = "aconite"

    elseif matches[2] == "c" then

    local venomone = "curare"

    end


    if matches[3] == "x" then

    local venomtwo = "xentio"

    elseif matches[3] == "k" then

    local venomtwo = "kalmia"

    elseif matches[3] == "d" then

    local venomtwo = "darkshade"

    elseif matches[3] == "de" then

    local venomtwo = "delphinium"

    elseif matches[3] == "p" then

    local venomtwo = "prefarar"

    elseif matches[3] == "e" then

    local venomtwo = "euphorbia"

    elseif matches[3] == "a" then

    local venomtwo = "aconite"

    elseif matches[3] == "c" then

    local venomtwo = "curare"

    end


    send("stand", false)

    send("dsl " .. target .. " head " .. venomone .. " " .. venomtwo, false)



    Why won't this work? :(


    Also, if it's because the things here don't work the way I think they do, any help trying to get it to be workable?

    When you declare a variable local within an if statement it's local to the scope of that if statement, so when you try to use venomone and venomtwo outside those if statements, they're nil. You can declare them both outside the if statements and then set them inside:

    local venomone="" --or whatever default you want
    if matches[2]=="x" then
       venomone="xentio"
    elseif matches[2]=="c" then
    ...
    end

    Personally, I'd make a table to clean things up a little bit, something like:

    local venomtable = {
      x = "xentio",
      c = "curare",
      a = "aconite",
      ....
    }

    local venomone = venomtable[matches[2]]
    local venomtwo = venomtable[matches[3]]

    send("stand")
    send("dsl "..target.." head "..venomone.." "..venomtwo)

    Functionality is the same, I just find it a little easier to read than the long strings of if statements. Also, if that table of venom abbreviations is something you're going to use in several aliases, you could define it in a script somewhere else (not as a local), and just call the same table in all your dsl aliases.
Sign In or Register to comment.