Looking for more active discussion? Join our Discord at https://discord.gg/x2s7fY6

Versatile targeting

AedenAeden Missouri
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

  • edited March 2018
    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 Rainbow
    ^kill (\w+)$
    target = matches[2];
    send("kill " .. target);

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

    Something like that?
    Aeden
  • AedenAeden Missouri
    yeah, like that actually. Thanks! Both of you
  • 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.
  • 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 Coffin
    You can use string processing to seperate it into a table of targets with space as the delimiter.
  • AedenAeden Missouri
    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.
  • edited March 2018
    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
  • It's that last part I don't know how to code. How do you step down your table list?
  • 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]
  • 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.