Targeting variables and Macros in Mudlet

edited December 2012 in Client Help
I don't know much lua and I only had a working knowledge of how to script in Lua before I  came here.

Here's my script:
alias name: target
pattern: ^tt(.+)$
big box::

target = matches[2]
echo("Target is set to".")

but when  I write target x I keep getting huh? and when i click on the green checked button, i get the echo but with the value of my variable unchanged.

It also means that my Key +  0 won't work on my target.

My macro is as follows:


^k$ <-- though it perhaps should be set to decay
key binding: key + 0
Big box:

It's much easier for me to set my targeting alias in cmud.

I can write it this way: target = %1;#echo Target is set to @target and it will echo the name of my target. I can't do that with my lua script for mudlet.
I also can assign my variable to say key +0 for decaying my target and assign . to fearing my target etc.

I would like to know what I can do to make my lua scripts work in mudlet...


  • Ok, there are quite a few issues here.

    1. Your targeting alias has the name "target" and the pattern "^tt(.+)$". The name of an alias in Mudlet is not what you need to type in your command box to call it. That's what the pattern is for. As it is set now, you need to type "ttiocun" to target "iocun" or "ttrat" to target rat. If you wish to type "target rat" or "target iocun" in order to target a rat or iocun, you need to change your pattern to: ^target (.+)$
    You can leave the name as it is, it is relatively irrelevant right now.

    2. Your echo is a bit messed up too. It should be: echo("Target is set to "".")
    The purpose of the "concatenation" dots .. in such echos is to "glue" two strings together to form a single one. Here, you have three strings: "Target is set to " is the first. The contents of your variable target is the second. A single full stop is the third. So you put those three strings after each other, and put .. between each pair of them, to concatenate them to a single string, which echo can then output.

    3. A key binding doesn't need any regex pattern like ^k$ at all. That's for aliases. Just leave the "command" box empty here, you don't need it.

    4. Your key binding does send("decay" Now remember what I wrote about concatenation dots to see what this will result in: You have the string "decay" and you have the string that is the contents of your target variable, let's say "rat". The two .. dots concatenate those two strings to a single one: "decayrat". Now, obviously, "decayrat" is nothing Achaea understands. It should be "decay rat". To get this result, you need to make sure to have a space at the end of the "decay " string. So your send should be: send("decay "..rat)
  • Thanks for the input. I will try this out the next time I log in and let you or others know how this works out.
  • edited December 2012
    I'm afraid this isn't working.

    Here's the new setup:

    alias name: Targets
    pattern: ^t (.+)$
    target = matches[2]
     echo("Target is set to "".") <-- i tried setting it to t but that didn't work. Echo doesn't work with this alias.

    I changed my macro like this:

    name: decay
    command: <-- i tried putting send(decay"") in there but that i didn't work. right now command is blank.
    big box: send(decay "") key won't fire even though I have it activated. there's a green check on it.

  • In the alias, you should add a $ at the end of the pattern: ^t (.+)$. The ^ and $ mark the beginning and end of the input line, respectively, so that the pattern will only match if you enter that and only that (i.e. it won't match substrings of the input line). That said, I would still expect "t rat" to set target = rat and echo "Target is set to rat." with what you have, so I'm not sure exactly what's wrong. You might want to add a \n to the beginning of your echo: echo("\nTarget is set to ""."). That will make it echo on a new line, instead of just after the previous prompt, making it more visible. That's just personal taste, though.

    In the macro, the send() still isn't quite right. Should be send("decay " Not really sure what "Key + 0" means in the keybinding. Is "key" just a stand-in for something like alt/ctrl/whatever there?
  • key + o  is simply the name of the key that is bound to my macro. it's right below the 1 to 9 keyset on my keyboard. I have the 1 to 9 set to directions from sw to ne on those numbers. There are no modifiers like shift or control for this key.

    I will give this a try. I forgot to add the scalar at the end of my pattern.. Thanks for pointing this out..I'll see about fixing my macro as well.
  • edited December 2012
    I have good news. I got it to work though I still can not make it echo my target in my alias.
Sign In or Register to comment.