Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

Targeting variables and Macros in Mudlet

RixieRixie Member Posts: 5
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 ..target".")


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:

Name:

decay
command:
^k$ <-- though it perhaps should be set to decay
key binding: key + 0
Big box:
send("decay"..target)

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...






Comments

  • IocunIocun Member Posts: 3,506 @@ - Legendary Achaean
    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 "..target..".")
    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"..target). 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)
  • RixieRixie Member Posts: 5
    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.
  • RixieRixie Member Posts: 5
    edited December 2012
    I'm afraid this isn't working.

    Here's the new setup:

    alias name: Targets
    pattern: ^t (.+)$
    bigbox:
    target = matches[2]
     echo("Target is set to "..target..".") <-- 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"..target") in there but that i didn't work. right now command is blank.
    big box: send(decay "..target") key won't fire even though I have it activated. there's a green check on it.




    Post edited by Rixie on
  • EldEld Member Posts: 3,946 @@ - Legendary Achaean
    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 "..target.."."). 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 "..target). Not really sure what "Key + 0" means in the keybinding. Is "key" just a stand-in for something like alt/ctrl/whatever there?
  • RixieRixie Member Posts: 5
    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.
  • RixieRixie Member Posts: 5
    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 to Comment.