Fiendish's mini window. Help adding another wildcard?

Posted by Wuggly on Sun 17 Jan 2016 03:21 PM — 7 posts, 29,357 views.

USA #0
Sorry about the subject, didn't know how to word my problem. (brain injury)

I am using gammon's adaption of Friendish's mini chat window. It works great, except sometimes when you are in combat, the chat will go on the same line as your health bar.

Let me try to make this more clear with some examples.

Normally when you say, tell, gossip, etc. the MUD I play makes a new line and puts it under the health bar, or prompt, or whatever it's called.


<500hp(500) 500ma(500) 500mv(500)(500) 500gp sp: [commn] > 
You say (in common), 'test'.


However, sometimes when you are in combat, it puts it on the same line as the health bar, or prompt, or whatever it's called.


<500hp(500) 500ma(500) 500mv(500)(500) 500gp sp: [commn] > You say (in common), 'test'.


When it goes on the same line, it fails to echo it in the miniwindow. I managed to make a temp. fix by adding more triggers.


    <trigger
    enabled="y"
    match="You say (in common), '*'."
    script="chats"
    omit_from_output="y"
    sequence="100"
    ></trigger>

    <trigger
    enabled="y"
    match="* You say (in common), '*'."
    script="chats"
    omit_from_output="y"
    sequence="100"
    ></trigger>


So with that temp. fix, when chat happens on the same line as the health bar, it does echo it in the miniwindow, except it also echos the entire health bar.

What I'm trying to do is make it so it omits the health bar when the chat screws up like that in game and goes on the same line as the health bar.

I'm thinking I need to make a new chats function for the triggers that catch the health bar so it can be omitted from the miniwindow, but I'm already way over my head with this, and hoping for some help.

Like for the * You say (in common), '*'. one it would send it to chatsa instead of chats.

Here's chats function.


function chats (name, line, wildcards, styles)
    
    -- echo in this world as well if the user wants
    if echo then
        for _, v in ipairs (styles) do
            ColourTell (RGBColourToName (v.textcolour),RGBColourToName 

(v.backcolour),v.text)
        end -- for each style run
        Note ("")  -- wrap up line
    end -- echo wanted

    -- inject timestamp if wanted
    if timestamp then
        local tstamp = os.date (date_format)
        table.insert (styles, 1, {
          text = tstamp,
          textcolour  = ColourNameToRGB (TIMESTAMP_TEXT_COLOUR),
          backcolour = ColourNameToRGB (TIMESTAMP_BACK_COLOUR),
          length = string.len (tstamp),
          style = 0,
        } )
    end -- if


Here is what I am wanting to do, and from what I read googling, ipairs wouldn't work like this, but this is just to try to make things more clear what I am wanting.


function chatsa (healthbar, name, line, wildcards, styles)


Now I do capture the hp for another trigger like this.

<*hp(*) *ma(*) *mv(*)(*) *gp sp: [*] > *

then it runs

hp = "%1"
SetVariable("hp", hp)


I'm very very very new to lua and for that matter, any programming language, so I don't imagine the way I define the variable is correct, but it works, so I've left it that way lol. Able to call it from other triggers with GetVariable and has been working perfectly.

I'm thinking I need to somehow redo the way I capture the health bar, putting every * into a variable like I did with the hp, and then somehow use it for the miniwindow so I can omit it.


Sorry if this is all too confusing or too little or too much information.

I hope from this mess of a post you can understand my problem, how I am trying to fix it, and what I am needing help with.

If not please ask me anything and I will do my best to answer.
Australia Forum Administrator #1
Template:faq=11
Please read the MUSHclient FAQ - point 11.


If you could force the prompt onto a new line, the other issues would go away.
USA #2
I think I'm getting closer, just not quite there yet. The "Convert IAC EOR/GA to new line" didn't work on the MUD I play, so I tried using the simpler plugin from
http://mushclient.com/forum/?id=7430

I have a feeling it's because I am not capturing the prompt line right.

First I tried.


  return (string.gsub (s, "\n<.+hp(.+) .+ma(.+) .+mv(.+)(.+) .+gp sp: [.+] .*> ", "%1\n"))


So then I tried


  return (string.gsub (s, "\n<*hp(*) *ma(*) *mv(*)(*) *gp sp: [*] > * ", "%1\n"))


The prompt line is like this


<500hp(500) 500ma(500) 500mv(500)(500) 500gp sp: [commn] > 


Am I doing it completely wrong?
Australia Forum Administrator #3
Square brackets have a special meaning in regexps, so I suggest putting a "%" in front of them, eg.


%[*%]





Also, "*" is a "zero or more" repeater, but you have to say zero or more of what, eg.


%d*ma(%d*)


Where "%d" is a digit, so "%d*" is zero or more digits. It might be better to use "one or more" like this:


%d+ma(%d+)





Also <grin> round brackets also have a special meaning so put a % in front of them as well.
Amended on Mon 18 Jan 2016 12:59 AM by Nick Gammon
Australia Forum Administrator #4
This test demonstrates the idea:


test = "\n<500hp(500) 500ma(500) 500mv(500)(500) 500gp sp: [commn] > blah blah blah"

print ((string.gsub (test, "\n<%d+hp%(%d+%) %d+ma%(%d+%) %d+mv%(%d+%)%(%d+%) %d+gp sp: %[.+%] .*> ", "%1\n")))



Output:


<500hp(500) 500ma(500) 500mv(500)(500) 500gp sp: [commn] > 
blah blah blah


Notice the newline inserted as expected.
USA Global Moderator #5
Honestly, I think the real problem is that:
Quote:
sometimes when you are in combat, it puts it on the same line as the health bar, or prompt, or whatever it's called.


All scrolling status prompt messages should end with newlines. This should not be debated. The reason why is because otherwise it causes exactly what you're seeing here. It's otherwise not really possible to safely anchor trigger patterns[1], and then you either get missed triggers or easily misfired[2] triggers. Both of those are bad.

Is it possible to ask in-game whether there is a way to make sure that doesn't happen? Because in my opinion that's either a server bug or a misconfigured prompt setting. Does your MUD have different settings between regular prompts and combat prompts?




[1] - For a description of anchoring, see something like https://msdn.microsoft.com/en-us/library/h5181w5w.aspx

[2] - If you don't/can't differentiate between a message that normally comes from the MUD on its own line and something that looks like that message embedded in something else (speech, notes, room descriptions), then you can't stop the trigger from firing on the something else too.
Amended on Mon 18 Jan 2016 11:41 AM by Fiendish
USA #6
I'll be sure to email and let the game devs know.

So far though, I haven't been able to get it to force a new line.

Here's what I tried so far, out of this code. I also tried the partial line one, but I guess that kind of stuff is still way over my head for now.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, October 22, 2006, 7:40 AM -->
<!-- MuClient version 3.82 -->

<!-- Plugin "Add_NewLine_To_Prompt" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Add_NewLine_To_Prompt"
   author="Nick Gammon"
   id="1f68b8da856ceccb6f2ea308"
   language="Lua"
   purpose="Forces a newline after a prompt line"
   date_written="2006-10-22 07:38:36"
   requires="3.82"
   version="1.0"
   >

</plugin>


<!--  Script  -->


<script>
<![CDATA[
function OnPluginPacketReceived (s)
  return (string.gsub (s, "\n<%d+hp%(%d+%) %d+ma%(%d+%) %d+mv%(%d+%)%(%d+%) %d+gp sp: %[.+%] .*>", "%1\n"))
end -- function OnPluginPacketReceived
]]>
</script>

</muclient>


Have tried.


"\n<%d+hp%(%d+%) %d+ma%(%d+%) %d+mv%(%d+%)%(%d+%) %d+gp sp: %[.+%] .*>", "%1\n"

"<%d+hp%(%d+%) %d+ma%(%d+%) %d+mv%(%d+%)%(%d+%) %d+gp sp: %[.+%] .*>", "%1\n"

"*<%d+hp%(%d+%) %d+ma%(%d+%) %d+mv%(%d+%)%(%d+%) %d+gp sp: %[.+%] .*>", "%1\n"

"\n<%d+hp%(%d+%) %d+ma%(%d+%) %d+mv%(%d+%)%(%d+%) %d+gp sp: %[.+%] >", " %1\n"

"<%d+hp%(%d+%) %d+ma%(%d+%) %d+mv%(%d+%)%(%d+%) %d+gp sp: %[.+%] .*> ", " %1\n"

"\n<%d+hp%(%d+%) %d+ma%(%d+%) %d+mv%(%d+%)%(%d+%) %d+gp sp: %[.+%] .*> *", " %1\n"



Those among other variations, trying different little things like that.

Now, I also have some triggers that highlights the entire line when someone chats. Do you think that could be messing with the newline any?