Need help with Mudlet Alias! Thank you!

Hi! I just started playing Achaea again and this is the first time I've used Mudlet. I've used other clients that I'm more familiar with when it comes to alias, triggers, regex, etc.

But I'm just learning with Mudlet. So any help would be greatly appreciated.

I'm trying to make an alias that uses hydra armclamp on my target and the arm I chose.

My alias looks like this, thus far:

Name: Hydra Armclamp

Pattern: ^hac(\w+)$

arm = matches[2]
send("Hydra armclamp"..target..arm)

The output I'm getting is:

hydra armclamp joeleft

So, it's recognizing my target from my targeting alias and it's recognizing which arm, but there's no space between the target and the arm.

I'm sure this probably an easy fix and any help would be great! It'll be another small step to improving my proficiency with Mudlet. Thank you very much.

Comments

  • send("Hydra armclamp"..target.. " "..arm)
  • Thanks for the idea! 

    I tried it and ended up having to do:

    send("Hydra armclamp".." "..target.. " "..arm)

    But it worked! Thank you so much.
  • Actually!

    send("Hydra armclamp"..target.. " "..arm)

    works fine if you put a space in after armclamp! :D
  • edited February 2014
    Not as useful here, but for more complicated things (especially printing to the screen), something like this helps to make it readable...

    send (string.format ("hydra armclamp %s %s", target, arm))

    Explanation: string.format takes 2+ arguments - the first is the string (with %s in this case where the variables are inserted) and the rest are the variables used in the string.

    I know it's MUSHclient documentation, but this document is really good: http://www.gammon.com.au/scripts/doc.php?lua=string.format
    Current scripts: GoldTracker 1.2, mData 1.1
    Site: https://github.com/trevize-achaea/scripts/releases
    Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
    Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.
  • The larger point here is that concantenating strings (i.e., joining them together with ..) just joins them exactly as is, so if you want spaces in there, you need to make sure they're included explicitly. So, as you found, send("hydra armclamp "..target.." "..arm) or send("hydra armclamp".." "..target.." "..arm) would both work, though the latter is obviously a bit more cumbersome.
    If you want something that's cleaner for more complicated strings, it would be worth looking into the string.format() function. In this case, you could do send(string.format("hydra armclamp %s %s",target,arm)), where the %s indicates a wildcard with a value specified by the subsequent function arguments. It's a bit more complicated, especially for simple stuff like this, but can make for much more readable code in more complicated cases.
  • I will definitely read up. I'm all about improving my capabilities. Thanks a ton!
Sign In or Register to comment.