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

Mudlet trigger help

RinkelRinkel Posts: 9Member
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

  • AntoniusAntonius Posts: 4,120Member @@ - Legendary Achaean
    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
  • RinkelRinkel Posts: 9Member
    I will give it a go, thank you!
  • KoganKogan Posts: 264Member ✭✭✭ - Distinguished
    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.
  • RinkelRinkel Posts: 9Member
    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

  • AntoniusAntonius Posts: 4,120Member @@ - Legendary Achaean
    @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.
  • TorinnTorinn Posts: 480Member ✭✭✭✭ - Eminent
    What's the difference between target and target:title()?
    Deucalion says, "Torinn is quite nice."
  • RinkelRinkel Posts: 9Member
    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
  • AntoniusAntonius Posts: 4,120Member @@ - Legendary Achaean
    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.

    Kyrra
  • TorinnTorinn Posts: 480Member ✭✭✭✭ - Eminent
    Aha very interesting! Thanks for explaining that
    Deucalion says, "Torinn is quite nice."
  • RinkelRinkel Posts: 9Member
    To save making a new thread, anyone know how to enable/disable folders/groups with a macro or alias?

    Thanks
  • AntoniusAntonius Posts: 4,120Member @@ - Legendary Achaean
    @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").
  • CaelanCaelan Posts: 664Member ✭✭✭✭ - Eminent
    Should be :-1:
    enableTrigger("Trigger name")
    disableTrigger("Trigger name")
    
    and for groups, it's just enableTriggerGroup("name") etc
    
    

    Sobriquet
  • RinkelRinkel Posts: 9Member
    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.
  • AntoniusAntonius Posts: 4,120Member @@ - Legendary Achaean
    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 Caer WitrinPosts: 2,741Member @@ - Legendary Achaean
    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...

    image

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

    Vadimuses
  • ShubShub Posts: 6Member
    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.

  • RinkelRinkel Posts: 9Member
    Seems to be different ones for groups of keys/alias etc

    enableKey("bla bla")

    enableAlias("bla bla")
Sign In to Comment.