Mudlet trigger help

Hi. Need help with making a trigger which will match to my target.
I eventually managed to make an alias using ..target.. but can't figure out how to match it in a trigger.

For example?
You suddenly perceive the vague outline of an aura of rebounding around target.

Thanks

Comments

  • The easiest way is to use a perl regex trigger with the name as a matched group, then compare in the trigger code.

    Perl regex pattern: ^You suddenly perceive the vague outline of an aura of rebounding around (\w+)\.$

    Code:
    if matches[2] == target:title() then
        -- some code
    end
  • I will give it a go, thank you!
  • Antonius said:
    The easiest way is to use a perl regex trigger with the name as a matched group, then compare in the trigger code.

    Perl regex pattern: ^You suddenly perceive the vague outline of an aura of rebounding around (\w+)\.$

    Code:
    if matches[2] == target:title() then
        -- some code
    end
    This. Essentially if you do t kogan to target me your target variable is stored as "kogan" so it wouldn't match to rebounding around Kogan. "kogan" ~= "Kogan" is the short explanation of it. I found it easier to change my targeting aliases to target = matches[2]:title() so if I made new triggers I could use target or target:title() and I'd never run into an issue where it wouldn't match.
  • Targeting etc working great now thanks. Got another problem i am stuck with. Trying to it wield bow if not wielded when i use key to fire. Using this so far and does not seem to work.

    send ("shoot " ..target.. " sw", true)

    if not wieldingbow then

    sendAll ("unwield scimitar", "unwield scimitar", "wield bow", true)

    send ("shoot " ..target.. " sw", true)

    else

    send ("shoot " ..target.. " sw", true)

    end

    and got triggers that are just wieldingbow = true/false when wielded or unwield.


    However does not work just tryed wielding either way.

    Thanks

    PS I am trying to do this first for ages and still can't get it not coded since zmud/cmud and that was alot easier

  • @Rinkel While it doesn't really teach you anything about coding, the answer is to not bother. The game will handle unwielding if required for you. You can just send WIELD BOW and it will only do it if you don't have it wielded.
  • What's the difference between target and target:title()?
    Deucalion says, "Torinn is quite nice."
  • Antonius said:
    @Rinkel While it doesn't really teach you anything about coding, the answer is to not bother. The game will handle unwielding if required for you. You can just send WIELD BOW and it will only do it if you don't have it wielded.

    Your right it didn't help the coding but less spammy. Thanks
  • Torinn said:
    What's the difference between target and target:title()?

    It depends on the value of target, but probably the difference between it being all lowercase and it being the right case to match the trigger text.

    If you have an alias with the pattern "^t (\w+)$" and the code "target = matches[2]", you're probably going to call it by typing in "t antonius" (who bothers with capitalisation when they're targetting people in a raid?). That means the target variable will have the value "antonius". Lua's string matching is case-sensitive, so "Antonius" (from the trigger) isn't equal to "antonius" (from the variable), and wouldn't match. The title() function will force the string to "title-case", which essentially just means it capitalises the first character (it doesn't do anything to the rest).

    You're better off changing your targetting alias to do "target = matches[2]:title()", since then the variable always has the correct case, and any code you write that compares it to trigger text will work without needing to call :title() every time.

  • Aha very interesting! Thanks for explaining that
    Deucalion says, "Torinn is quite nice."
  • To save making a new thread, anyone know how to enable/disable folders/groups with a macro or alias?

    Thanks
  • @Rinkel As far as I recall, use the corresponding disableX function for whatever type of group it is. For example, if you want to disable a group of triggers called "My Triggers", you'd use disableTrigger("My Triggers").
  • Should be :-1:
    enableTrigger("Trigger name")
    disableTrigger("Trigger name")
    
    and for groups, it's just enableTriggerGroup("name") etc
    
    

  • Caelan said:
    Should be :-1:
    enableTrigger("Trigger name")
    disableTrigger("Trigger name")
    
    and for groups, it's just enableTriggerGroup("name") etc
    
    
    Cheers! Found the section regarding all this in the wiki now thanks to that.
  • Caelan said:
    Should be :-1:
    enableTrigger("Trigger name")
    disableTrigger("Trigger name")
    
    and for groups, it's just enableTriggerGroup("name") etc
    
    
    Was the enableTriggerGroup function added in 3.x? It's not listed in any of the Mudlet documentation.
  • ShirszaeShirszae Santo Domingo
    From what I recall, you enable groups with enableTrigger("") same as with normal triggers. You just need to make sure they have unique names.

    And you won't understand the cause of your grief...


    ...But you'll always follow the voices beneath.

  • I have a targeting alias on pattern ^t (.+)$

    mt = matches[2]
    target = matches[2]
    cecho("<light_slate_blue>My target is now: <red>"..mt.."\n")

    and a corresponding trigger that replaces "$mt" with the target, pattern is
    ^(.*) \$mt

    --cecho("<light_slate_blue>command:<red>"..matches[2] .." ".. mt.."\n")
    send(matches[2] .." ".. mt)

    I have a few triggers and gui links that set that mt variable as well, but most of the time its just "t pygmy", "drawslash $mt", etc.


  • Seems to be different ones for groups of keys/alias etc

    enableKey("bla bla")

    enableAlias("bla bla")
Sign In or Register to comment.