[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Fiendish's mini window. Help adding another wildcard?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Fiendish's mini window. Help adding another wildcard?

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Wuggly   USA  (112 posts)  [Biography] bio
Date Sun 17 Jan 2016 03:21 PM (UTC)
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 17 Jan 2016 08:11 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Wuggly   USA  (112 posts)  [Biography] bio
Date Reply #2 on Sun 17 Jan 2016 10:23 PM (UTC)
Message
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?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 18 Jan 2016 12:56 AM (UTC)

Amended on Mon 18 Jan 2016 12:59 AM (UTC) by Nick Gammon

Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Mon 18 Jan 2016 01:05 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #5 on Mon 18 Jan 2016 11:07 AM (UTC)

Amended on Mon 18 Jan 2016 11:41 AM (UTC) by Fiendish

Message
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.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Wuggly   USA  (112 posts)  [Biography] bio
Date Reply #6 on Wed 20 Jan 2016 01:03 PM (UTC)
Message
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?
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


3,227 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]