Versatile targeting

AedenAeden MissouriPosts: 38Member
If anyone uses mudlet, do anyone know how to code the pattern that allows you to preset the target OR just type in the name of the target?

^tt (\w+)$ <--- is what I use to preset target before choosing to do something to it.

translates:tt testdog
send("kill " testdog)

but I just need the pattern to where I can do either, and when I do send("kill ", I can just do like kill dog/kill cat/kill something. Without having to keep presetting a target each time a target is changed.


  • XeniaXenia Posts: 922Member ✭✭✭✭✭
    edited March 9
    Change the variable of target from a string to a table and then change your attack to attempt on every object in the table.
  • EliadonEliadon Somewhere Over the RainbowPosts: 83Member ✭✭✭
    ^kill (\w+)$
    target = matches[2];
    send("kill " .. target);

    send("kill " .. target);

    Something like that?
  • AedenAeden MissouriPosts: 38Member
    yeah, like that actually. Thanks! Both of you
  • MihaketiMihaketi Posts: 86Member ✭✭✭
    Personally what I do is make an alias that takes a list of targets ('t dog cat something') and upon failing to hit something in the room, changes to the next entry in the table.
  • InsadiaInsadia TexasPosts: 2Member
    Mihaketi said:
    Personally what I do is make an alias that takes a list of targets ('t dog cat something') and upon failing to hit something in the room, changes to the next entry in the table.
    What does that code look like?
  • EvalyneEvalyne A CoffinPosts: 109Member ✭✭✭
    You can use string processing to seperate it into a table of targets with space as the delimiter.
  • AedenAeden MissouriPosts: 38Member
    Actually I made an error there, I meant for an alias to execute the desired action upon a target on the fly if I need to change targets on the next balance, and not have to preset target THEN execute said alias. To which, I found it to be actually this as an example: so that way I can just do "lea testdog" or just "lea" if the target is current.
  • MihaketiMihaketi Posts: 86Member ✭✭✭
    edited March 11
    Insadia said:

    What does that code look like?
    In the case of my Mudlet system:
    Alias pattern: ^t (.+)$ Script: if matches[2]:lower() == "clear" then modules.targets.all = {} modules.targets.primary = "nobody" echo("\nTarget cleared.") else modules.targets.all = {} for s in matches[2]:gmatch("%w+") do table.insert(modules.targets.all,s) end if #modules.targets.all > 0 then modules.targets.primary = modules.targets.all[1] echo("\nTarget: "..modules.targets.primary) else echo("\nNo valid targets.") end end

    and then in the 'you cannot see that target' trigger you just step up or down modules.targets.all.
  • InsadiaInsadia TexasPosts: 2Member
    It's that last part I don't know how to code. How do you step down your table list?
  • MihaketiMihaketi Posts: 86Member ✭✭✭
    Keep track of your current position in the table and increase or decrease it as needed.
    target_index = target_index or 1 if increasing then target_index = target_index + 1 if target_index > #all_targets then target_index = 1 end else target_index = target_index - 1 if target_index < 1 then target_index = #all_targets end end current_target = targets[target_index]
  • IrruelIrruel Posts: 667Member ✭✭✭✭
    Something else you might like, in the aliases for attacks rather than the targeting alias:


    local tar = matches[2] or target
    send('slash ' .. tar)

    So, typing 'slash' will slash whatever target you have set.
    Override that for a single attack by typing 'slash soandso'

    If you wanted, you could choose to set that as your new target as well, or even combine Miha's script and set lists of targets from the attack alias.

    Personally I don't bother taking it that far - I just like being able to use my attack aliases without changing my current target.

Sign In or Register to comment.