Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Fflam's Silly Mudlet Question Repository

FflamFflam Member Posts: 7
I figure if I can't figure it out, somewhere, someone else won't be able to figure it out - so we'll get it in writing!

Right now, all I'm trying to do so streamline my bashing - remove the wordy attacks and replace them with short and sweet gags, keeping relevant information in front of me.

So far, I have my current stance on my prompt (thanks, forums) and I have managed to get what is ALMOST working triggers for the basic lateral/vertical knifeplay attacks.  My problem jumps in when (I think) there are multiple words in a mob's name, OR when there is an apostrophe in the mob's name.

^You step in quickly with a slash across (\w+) torso\.$

selectString( line, 1 )
replace("")
cecho("<white>ATTACK:<red>LATERAL")

I think there needs to be a way to signify the apostrophe, as I believe (\w+) catches any number of words, but I'm not seeing a fix in documentation as the examples are specific.

Once we've sorted this as solved I'll edit the post with the answer and move on to figuring out how to put multiple things on my prompt without a custom prompt (SPOILER: I think I need multiple prompt triggers)

Comments

  • GaltGalt Member, Beta Testers Posts: 305 ✭✭✭
    edited March 2018
    There are a few options here. You could use a regex pattern to match letters, spaces and stuff like apostrophes, or use a wildcard.

    Wildcard would look like: 

    ^You punch ([a-zA-Z'\s]+) in the face.$

    ( ) denotes the capture group, a-z is any lowercase letter, A-Z any uppercase, ' to match the apostrophe and \s to match the spaces. [] makes it a character set, and the + makes it "1 or more", so any string with 1 or more of those characters is matched. 

    Alternately, in case any mob has other things in its name, you could do:

    ^You punch (.*) in the face.$

    That will match anything in that gap. 

    To delete and replace the line, you can just do:

    deleteLine()
    cecho("Blah")

    And to add extra stuff to the prompt you can just have it in multiple echos/an echo in your prompt trigger.

    The way I handle this is:

    function extraPrompt()
    cecho("B: "..myBleeding)
    end
    That would just chuck a B: 123 on my prompt for my bleeding, if I call the extraPrompt() function in my prompt trigger. You can get pretty complex with this using if statements and selective echoing, for example:

    function extraPrompt()
    if myBleeding>=1 then
    cecho("B: "..myBleeding)
    end
    end

    That would hide myBleeding if it was 0. You can build on this - Adding more complicated things, more information, selective formatting etc. I have an "s" for shield, which is uppercase and cyan if I'm shielded, lowercase and grey if not. The below example assumes if you're shielded, then myShielded is set to true, if not, it's set to false.

    function extraPrompt()
    if myBleeding>=1 then
    cecho("B: "..myBleeding)
    end
    if meShielded then
    cecho("<cyan>S")
    else
    cecho("<grey>s")
    end
    end
    
Sign In or Register to comment.