Help highlighting target and enemies?

One day, I will run out of questions about Mudlet.

1. How can I highlight my target variable?  No matter what I try, I can't seem to get it work.

2. How can I highlight those people on my enemies list?  I just recently learned how to sort of use tables, and I'm assuming you'd use a table for this.  I just can't figure out how :(

Thanks!

Best Answers

Answers

  • ElanorwenElanorwen The White Falconess
    The only way I've discovered is using temporary triggers that will color stuff. So every time I switch target/influence target, it deletes the old temp trigger (if it exists) and creates a new one.
    image

    Forgiveness is the fragrance that the violet sheds on the heel that has crushed it.
  • KioKio
    edited April 2013
    Ushaara said:
    Following should work and is flexible, though there may be speedier way of doing it. Your enemies_table would be of form  { "Ushaara", "Rivius", etc. }
    trigger pattern: return not isPrompt() <- lua function type

    -- highlighting enemies
    enemies_table = enemies_table or {}
    for _,name in pairs(enemies_table) do     if line:find(name) then selectString(name, 1) fg("red") resetFormat() end end
    -- similar for basic target
    target = target or "weevil"
    if line:find(target) then selectString(target, 1) fg("yellow") resetFormat() end
    You will need to watch for case-sensitive things, so string.lower(word) and string.title(word) functions come in handy there.
    I'm afraid I don't understand the trigger pattern. :(
  • KioKio
    edited April 2013
    Huzzah!  Learning!  Thank you!

    BAHAHA!  Everything is working perfectly.  SO MUCH LEARNING.
  • When my target is also an enemy, the enemy color is used. How can I change this?
  • How can I save the entries of a table so that they're not cleared when I exit Mudlet?
  • UshaaraUshaara Schrödinger's Traitor
    Try adding remember("enemies_table") to a logout alias/trigger.
  • So, I have two tables: one for permanent enemies and one for permanent allies.  I'm trying to highlight my enemies yellow and my allies purple.  I have two triggers for this, both are triggered off:

    return not isPrompt()

    The ally trigger is:

    allies_table = allies_table or {}

    for _,name in pairs(allies_table) do

    if line:find(name) and target ~= name then selectString(name, 1) fg("purple") resetFormat() end

    end


    The enemy trigger is:

    enemies_table = enemies_table or {}

    for _,name in pairs(enemies_table) do

    if line:find(name) and target ~= name then selectString(name, 1) fg("yellow") resetFormat() end

    end


    The problem is that, for some reason, either all the names are yellow or all the names are purple.  Also, once I clear either list, the other list is suddenly highlighted that color (if I empty the purple enemies table, suddenly my yellow allies turn purple).


    I'm so bad at this.

  • It sounds like you're adding people to both lists somehow, because the code you shared seems to be fine.

    Make sure whatever you're doing to add people to enemies_table isn't also adding them to allies_table?
    Take great care of yourselves and each other.
Sign In or Register to comment.