Mudlet and string.format

Hey folks, had a quick question about string.format.  I blatantly ripped off some code from http://www.lusternia.com/node/30027, specifically the bit that Vadi had posted towards the bottom.  I'm curious if it's possible to change color dynamically in there based on the wounds state of your target when you assess them.  For example, if it comes back that someone is at heavy head wounds, I'd like for either the entire line or just the bit where it displays headwounds to be orange, while the rest of the display is normal "no wounds here boss!" colors.  Pretty sure I could just write a function to echo/cecho the lines in what colors I want based on the value of xwounds, but I do like the elegance that is the one big string.format.
image

Comments

  • cecho("wounds", string.format([[
    *******TARGET WOUNDS********
    * TARGET : %s
    * Health : %s
    * --------------------------
    %s* Head Wounds : %s
    %s* Chest Wounds : %s
    ]], target, targethealth, headwoundscolor, headwounds, chestwoundscolor, chestwounds)


    Just run the entire thing through cecho, and before calling the cecho set variables for the colors, so if headwounds is 'heavy' or worse, set headwoundscolor to "orange", and otherwise set it to "white" or "reset" or whatever your 'normal' color is.

  • TarkentonTarkenton Traitor Bear
    Awesome Cern, thanks.  Dunno why I didn't think of something like that in the first place.
    image
Sign In or Register to comment.