[HTML] Sawbones highlighting

Some folks were very helpful in putting this together, so I thought I'd put it here, free for anybody to use.  It highlights your lines in Sawbones so that you can better see your prep progress.

In your onLoad function, add the following:

// Sawbones
var limbName;
var limbStatus;
client.reflex_enable(client.reflex_find_by_name("trigger", "limbprepped", true, true));
Then create a trigger called limbprepped (you can name it whatever you like as long as you change the argument in the client.reflex_enable function):

^(Right leg|Left leg|Right arm|Left arm|Torso|Head): \s+ (Perfect health|Barely damaged|Lightly damaged|Moderately damaged|Heavily damaged|Crippled)$
In this trigger, copy and paste the following:

limbName = args[1];
limbStatus = args[2];

if (args[2].match(/Perfect health/)) {
    client.current_line.parsed_line.colorize(0, 30, 'black', 'white');
}
if (args[2].match(/Barely damaged/)) {
    client.current_line.parsed_line.colorize(0, 30, 'black', 'green');
}
if (args[2].match(/Lightly damaged/)) {
    client.current_line.parsed_line.colorize(0, 30, 'black', 'yellow');
}
if (args[2].match(/Moderately damaged/)) {
    client.current_line.parsed_line.colorize(0, 33, 'black', 'orange');
}
if (args[2].match(/Heavily damaged/)) {
    client.current_line.parsed_line.colorize(0, 30, 'black', 'red');
}
if (args[2].match(/Crippled/)) {
    client.current_line.parsed_line.colorize(0, 30, 'white', 'black');
}
You can change the colors to whatever you like.  I haven't added lines for epseth/epteth/shatter/smash breaks.

Be sure to type "onLoad" in your prompt to get rid of the initial error messages.
~Kresslack's obsession~

Comments

  • edited November 2014
    The " \s+ " bit is strange. You're matching a space, then one or more spaces/tabs, then another space. Essentially, you're saying "three or more spaces" in a really strange, idiosyncratic way. I imagine it works, but it's weird.

    It also looks like you're not actually using the limbName thing. If that's the case, no point in saving it - change the first capture group to "(?:Right leg|...)" and you can just use args[1].
  • Tael said:
    The " \s+ " bit is strange. You're matching a space, then one or more spaces/tabs, then another space. Essentially, you're saying "three or more spaces" in a really strange, idiosyncratic way. I imagine it works, but it's weird.

    It also looks like you're not actually using the limbName thing. If that's the case, no point in saving it - change the first capture group to "(?:Right leg|...)" and you can just use args[1].
    Assuming that this is just a simple highlighter (which it is), I'm guessing the args[1] is there for people to later add other things, perhaps additions to their own limbcounter, echos or what have you. Maybe even a prompt tag to be added showing when that specific limb is prepped. I like to variable things sometimes even when I'm not currently using them just so if I later decide to come back and add something, I can just plug it in rather than change everything and debug.
  • Kross is correct, the assignment is there in case you want to expand upon the trigger for your own purposes.

    I have tested the trigger and it works for all instances, so \s+ has caused no problems, at least none that I could produce.
    ~Kresslack's obsession~
  • EldEld
    edited November 2014
    Addama said:

    I have tested the trigger and it works for all instances, so \s+ has caused no problems, at least none that I could produce.
    Right, it'll work for this, since it's just requiring that there be at least 3 spaces, and all the sawbones messages have more space than that. It's just a little odd, and something that could trip you up in future scripts, so worth being aware of. To be clear, @Tael wasn't saying that there was anything wrong with "\s+", itself, just that having extra spaces surrounding it, i.e.
      "...): \s+ (Perfect health|..."
    instead of
       "...):\s+(Perfect health|..."
     is strange.
  • edited November 2014
    Yes, although using \s+ in the first place is actually sort of strange. Particularly with the spaces around it, this looks to me like a common mistake people learning regex make, which will trip you up a lot later: thinking that letters are not just normal tokens and that the shorthand backslash character classes are somehow special rather than just being syntactic sugar. If you want multiple spaces, you can just put a + quantifier after a space.

    There are no tabs in the message, so all you actually need is " +".
Sign In or Register to comment.