[Mudlet] Trying to make a Targeting alias but.. not sure how (im a blademaster)

Pattern is ^tt(.+)$

target = matches[2]

echo("\nNow targeting " .. target .. "!")


but its not working and how do you target and use the drawslash command altogether?


any help would be appropriate.



Comments

  • NizarisNizaris The Holy City of Mhaldor
    edited March 2013
    I noticed that you don't have a space between the tt and (.+) matching group. Are you typing it with a space as you enter the alias on the command line?

    If you're not using a space, I recommend using one, anyway. Just make sure to adjust the regex in your pattern to reflect it.

    Also, I recommend defining target = nil in a script somewhere. I'm not sure, but I think that if you don't, the target variable is considered "local" to the alias, rather than being "globally" available to other functions as well (such as your attack alias).
    image
  • yes I put a space like this ^tt (.+)$ but when I try to use tt rat, it doesn't do anything
  • Nizaris said:
    I noticed that you don't have a space between the tt and (.+) matching group. Are you typing it with a space as you enter the alias on the command line?

    If you're not using a space, I recommend using one, anyway. Just make sure to adjust the regex in your pattern to reflect it.

    Also, I recommend defining target = nil in a script somewhere. I'm not sure, but I think that if you don't, the target variable is considered "local" to the alias, rather than being "globally" available to other functions as well (such as your attack alias).
    This is not true for lua. All variables are global unless explicitly declared local. Defining target=nil is exactly the same as not defining it at all.
  • Chidra said:
    yes I put a space like this ^tt (.+)$ but when I try to use tt rat, it doesn't do anything
    When you say it doesn't do anything, you mean you don't even get the echo? If that's the case, make sure that the alias is enabled. There should be a little checkmark in the box next to it in the alias editor. If that box is blank, just double click to enable it. If it has a little ladybug icon, there's an error in the script, and there should be an error message at the top of the window.

    As for using your drawslash with it, the simplest thing is just to make another alias with some pattern like ^ds$, and the script
        send("drawslash "..target)
    . With that, you'll be able to type "tt rat" to set your target to "rat" and then typing "ds" will send "drawslash rat".
  • both aren't work.. I typed every in the parts where they go but nothing is happening.
  • nevermind, got it to working
  • @Eld tried the drawslash alias but its not working, only the targeting one
  • edited March 2013
    Chidra said:
    @Eld tried the drawslash alias but its not working, only the targeting one
    Double check that you have it entered correctly. You have a working example with targeting now.  If it's entered correctly, is it activated? Is there another alias that has the same string or matching pattern, maybe it fires first and it's not doing anything or what's expected at the moment? Is the ^ds$ of type perl regex?

    Also like others have said, Lua is a global namespace language. "Encapsulation" or local variables are explict.

    Local:
    function blah ()
      local a = 1
      local b = 2
      ... 
    end
    variables a and b won't be able to be referenced outside function blah like they are inside the function.

    "Encapsulation":
    drauka = {}
    drauka.a = 1
    drauka.b = 2
    function drauka:blah ()
      drauka.a = 3
      drauka.b = 4
      ...
    end
    Variables drauka.a and drauka.b are in the drauka table or "namespace" as it's a sorta hack in Lua. Function drauka:blah is also in the drauka "namespace". drauka.a and drauka.b are technically still global and accessible from anywhere, but it's a clean way to deal with global namespace uniqueness so you don't have name clashing. Usually good practice to do this in Lua for anything of decent size.
  • @Drauka Regex is the only available pattern type for aliases.
  • Patern: ^ds$


    send("drawslash "..target) is all I did, and it isn't working.


  • Chidra said:
    Patern: ^ds$


    send("drawslash "..target) is all I did, and it isn't working.


    A bit more specifics on what you mean by "not working" might help. For now, I'm assuming you mean that after you've set a target with, say, "tt rat", you type "ds" and absolutely nothing happens.

    The only reasons I can think of for that not to work are if:
    1) The alias is not activated. I assume you've checked this. If you type "ds" and you don't get a line from the MUD indicating that it doesn't recognise the command, then the alias is active.
    2) For some reason, your target is not getting set properly. In the script editor, if you click the button marked Errors on the left sidebar (red circle with an exclamation mark), it should open a window where you can see error messages from failed scripts. If you see an error message along the lines of "attempt to concatenate a nil value" that means your target's not set properly. If you see some other error message, go ahead and copy/paste it here.
  • ok sorry I heres what it says, not sure on what to do next.. bare with me

    [ERROR:] object:<WindowResizeEvent> function:<handleWindowResizeEvent>
             <attempt to call a nil value>
    [ERROR:] object:<WindowResizeEvent> function:<handleWindowResizeEvent>
             <attempt to call a nil value>
    [ERROR:] object:<event handler function> function:<mmp_track_exits>
             <attempt to call a nil value>


  • None of those errors are related to the drawslash alias. This is after you've done "tt <target>" and "ds"? And you saw the "Now targeting <target>" echo when you did the "tt", but no output from Achaea when you did "ds"?
  • I typed in tt rat and it showed me targeting rat but it doesn't when I type in ds rat, it doesn't tell me anything. maybe I should make a trigger?
  • well someone told me to just setalias ds drawslash in the place where i type and it set it soo.. I just go along with that. @Eld thanks for the help and sorry I didn't know much about what I was doing, ill look into learning how to code sometime.

  • Chidra said:
    I typed in tt rat and it showed me targeting rat but it doesn't when I type in ds rat, it doesn't tell me anything. maybe I should make a trigger?
    Ah, the alias I gave was just for typing "ds" alone, not "ds rat", so it's not matching. The idea is that once you set the target, the drawslash alias will just take that target and use it, so you don't have to type it again. The setalias command sets an in-game alias using Achaea's builtin alias system, which also works fine, though it wouldn't hurt to learn a bit more about how mudlet aliases work if you're going to be using it in the future. A good place to start for that, if and when you want to dig into it a bit more, would be the Mudlet Manual.
  • edited March 2013
    Thanks for the site, ill look into it and hopefully learn more about mudlet. @Eld I finally got it! it should have been send("drawslash at " ..target) ...anyway thanks for the big help dude
  • wait... nevermind it doesn't work, it was the setalias ds that I saw :(

  • Yeah, the command is correct, it's just that you need to do "ds" instead of "ds rat".
  • ok I got it finally, lol thanks again
Sign In or Register to comment.