Versatile targeting

AedenAeden MissouriMember Posts: 38
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 " ..target)(kill testdog)

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

Comments

  • XeniaXenia Member Posts: 963 ✭✭✭✭✭
    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.
    image
  • EliadonEliadon Somewhere Over the RainbowMember Posts: 121 ✭✭✭
    ^kill (\w+)$
    target = matches[2];
    send("kill " .. target);

    ^kill$
    send("kill " .. target);

    Something like that?
    Aeden
  • AedenAeden MissouriMember Posts: 38
    yeah, like that actually. Thanks! Both of you
  • MihaketiMihaketi Member Posts: 86 ✭✭✭
    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 TexasMember Posts: 2
    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 CoffinMember Posts: 128 ✭✭✭
    You can use string processing to seperate it into a table of targets with space as the delimiter.
  • AedenAeden MissouriMember Posts: 38
    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:
    https://gyazo.com/13487fb15337d62b4961c9160455f18f so that way I can just do "lea testdog" or just "lea" if the target is current.
  • MihaketiMihaketi Member Posts: 86 ✭✭✭
    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.
    Aeden
  • InsadiaInsadia TexasMember Posts: 2
    It's that last part I don't know how to code. How do you step down your table list?
  • MihaketiMihaketi Member Posts: 86 ✭✭✭
    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 Member Posts: 668 ✭✭✭✭
    Something else you might like, in the aliases for attacks rather than the targeting alias:

    ^slash(:?\s(\w+))?$

    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.

    Aeden
Sign In or Register to comment.