In my favorite MUD, enemy difficulty is displayed as such:
Armor: *****
Damage:**** :
Health:******* :
Is there any way (and I won't be surprised if there isn't, but it couldn't hurt to ask) to count how many of those * there are? My hope is to turn the above output into something like this:
I don't think it's possible with regular expressions directly, however, I think you could capture on the string, omit it from output, and then send it to a script; the script would count the asterisks, and then output to world the original line plus the count of asterisks.
I did some research, so here's how I'm doing it in VBScript:
Itcounted = "%1"
world.send Len(Itcounted)
Unfortunately, it seems that this will count spaces as well, and that's not something I want. But more digging around and testing and such yielded the following solution:
function charcount(strRequest, char)
tmp = Split(Trim(strRequest), char)
charcount = UBOUND(tmp)
end function
The problem I have now is that it puts each of these "world.note"s on a new line instead of at the end of the one already there. Is there any way to replace the line or simply add the output at the end of the line its giving me?
If you omit the line from output, and then redisplay it (with world.Tell) it will appear without starting a new line. Then append, with world.Note the extra stuff you want.
Simple enough though that sounds, I'm afraid that I don't understand. See, whenever I "Omit from output," I can't get it to display anything, whether I world.note or world.tell.
I've had that problem before, but only until the mud sent back more text. Sometimes MC can set the world.note part farther down than the screen shows, but that might just be an issue with Wine.
Try putting a few messages in there to make sure the script engine is getting to your code. You can delete these test lines later, but they might point out when you're running into trouble.
sub rating( trig_name, trig_line, wildcards )
'test line
world.note "script called"
'
count = string.gsub(trig_line, "%*", "*")
world.note trig_line .. ": " .. count
end sub
If that doesn't help you out, just cut/paste your whole script into a post and we can take a look at it from there.
There has been a design issue with Omit from Output, and scripts that do a Note, for a while now.
Basically MUSHclient omits everything from the start of the matching line, to the end of the output buffer, including anything you note.
However in the latest version you can now do "send to script - after omit", which changes the order of things around a bit, and the Note (or Tell) will appear in the output window.
sub barcount( trig_name, trig_line, wildcards )
tmp = Split( Trim( wildcards[ 1 ] ), & )
world.note trig_line .. Cstr( UBound( tmp ) )
end sub
That should work... I think. I'm not very familiar with VBscript, since I haven't actually used it in a good 4-5 years. It should in theory display the lines just like you had them in your first post, and you can put this in your script section and have multiple triggers call it. Or you could use regex and have the trigger line be
I suggested making it "send to script - after omit". You had:
send_to="12"
This is "send to script". It should be 14 (script after omit). Just amend the drop-down box in the trigger. Then you should be able to omit from output, and still do your notes.