[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]  Lua
. . -> [Subject]  Working with the line
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Working with the line

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


Pages: 1  2  3 

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #30 on Sat 24 Sep 2016 10:17 PM (UTC)
Message
Quote:

For some reason, these don't end up matching.


It matched when I tested it. Maybe another trigger matched it first. Turn on Trace under the Game menu to find out what is happening.

- Nick Gammon

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

Posted by Tesagk   (51 posts)  [Biography] bio
Date Reply #31 on Sun 25 Sep 2016 01:09 PM (UTC)

Amended on Mon 26 Sep 2016 07:27 PM (UTC) by Tesagk

Message
Quote:

[bbpocket(#21){Core}<-(#20)] (New BB message (3/49) posted to 'OOC Discussion' by Trino Valve: RE: The Map...)
TRACE: Matched trigger triNoSpoofCapture
TRACE: Executing trigger script "pnp.nospoof.gather"
[bbpocket(#21){Core}<-(#20)] (New BB message (3/49) posted to 'OOC Discussion' by Trino Valve: RE: The Map...)


Upon a second look, I do believe that < isn't in the gsub, but I also don't believe it's a special character. So, I admit to being a little flummoxed. The trigger clearly sees it, but then doesn't remove it in the script.


pnp = pnp or {}
pnp.nospoof = pnp.nospoof or {}

function pnp.nospoof.gather(name, line, wildcards, styles)
    --print(wildcards[1])
    local noSpoof = string.gsub(wildcards[1], "[%^%$%(%)%%%.%{%}%[%]%*%+%-%?]", "%%%1")
    local outputted = false
    for k,v in ipairs(styles) do
        text = string.gsub(v.text, noSpoof, "")
        if not outputted then
          text = string.gsub (text, "^ ", "")
        end -- leading space on first output
        if #text > 0 then
          outputted = true
        end  -- if
        ColourTell(RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), text)
    end 
    
    Note()
end


As a secondary issue. I keep having to uncheck "omit from output" because the omission seems to east the redisplayed lines as well as the original.
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #32 on Sun 25 Sep 2016 07:57 PM (UTC)
Message
Template:version Please help us by advising the version of MUSHclient you are using. Use the Help menu -> About MUSHclient.

- Nick Gammon

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

Posted by Tesagk   (51 posts)  [Biography] bio
Date Reply #33 on Sun 25 Sep 2016 09:02 PM (UTC)
Message
Nick Gammon said:

(version)


5.02
[Go to top] top

Posted by Tesagk   (51 posts)  [Biography] bio
Date Reply #34 on Sun 25 Sep 2016 09:57 PM (UTC)
Message
Quote:

Testrin Sidle has arrived.
TRACE: Matched trigger triNoSpoofCapture
TRACE: Executing trigger script "pnp.nospoof.gather"
[SGP - Main Globals(#6){Core}<-(#30827)] GAME> Testrin Sidle goes IC.
@emit %[SGP - Main Globals(#6){Core}<-(#30827)%] GAME> Mathesan Madaur goes IC.
TRACE: Matched trigger triNoSpoofCapture
TRACE: Executing trigger script "pnp.nospoof.gather"
GAME> Mathesan Madaur goes IC.


Now this is particularly strange. When I try replicating the output from the game that doesn't match, IN THE GAME, it is parsed out just fine.

I'm completely lost.
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #35 on Mon 26 Sep 2016 04:44 AM (UTC)
Message
Quote:

When I try replicating the output from the game that doesn't match, IN THE GAME, it is parsed out just fine.


I don't understand what you are saying here. What does "parsed out just fine" mean? I'm not clear what is and isn't working and under what circumstances.

- Nick Gammon

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

Posted by Tesagk   (51 posts)  [Biography] bio
Date Reply #36 on Mon 26 Sep 2016 10:17 AM (UTC)
Message
Nick Gammon said:

Quote:

When I try replicating the output from the game that doesn't match, IN THE GAME, it is parsed out just fine.


I don't understand what you are saying here. What does "parsed out just fine" mean? I'm not clear what is and isn't working and under what circumstances.


It's all in the quote.

Using @emit, I can simulate output from the game (since @emit doesn't show nospoof data for my character's stuff).

In every instance of it not capturing (shared in previous posts, usually around lines containing "{Core}<-"), it captures just fine if the same line comes from the MU* through my own character's @emit. It redisplays the line, stripping out the "nospoof" data.
[Go to top] top

Posted by Tesagk   (51 posts)  [Biography] bio
Date Reply #37 on Mon 26 Sep 2016 05:52 PM (UTC)

Amended on Mon 26 Sep 2016 07:26 PM (UTC) by Tesagk

Message

pnp = pnp or {}
pnp.nospoof = pnp.nospoof or {}

function pnp.nospoof.gather(name, line, wildcards, styles)
    --print(wildcards[1])
    local noSpoof = string.gsub(wildcards[1], "[%^%<%$%(%)%%%.%{%}%[%]%*%+%-%?]", "%%%1")
    local outputted = false
    for k,v in ipairs(styles) do
        text = string.gsub(v.text, noSpoof, "")
        if not outputted then
          text = string.gsub (text, "^ ", "")
        end -- leading space on first output
        if #text > 0 then
          outputted = true
        end  -- if
        ColourTell(RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), text)
    end 
    
    Note()
end


One thing I've noted, upon review, is that the lines that aren't parsing the nospoof stuff out still have the timestamp indicator that ColourTell() is sending them. Which means it's something in the code that's failing.

I noticed that text is not a variable passed through the function and it's not declared in the function. Is it a global?

Quote:

pnp.nospoof.gather>
pnp.nospoof.gather> Mathesan Madaur has joined this channel.
Mathesan Madaur has joined this channel.
Channel Roleplay added with alias rp.
pnp.nospoof.gather>[SGP - Main Globals(#6){
[SGP - Main Globals(#6){pnp.nospoof.gather>Core
Corepnp.nospoof.gather>}<-(#21501)]
}<-(#21501)]pnp.nospoof.gather> <OOC> Trino Valve says, "So... I dunno."
<OOC> Trino Valve says, "So... I dunno."


Here you see some of the output I get when I add

print("pnp.nospoof.gather>"..text)


immediately after

text = string.gsub(v.text, noSpoof, "")
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #38 on Mon 26 Sep 2016 08:22 PM (UTC)
Message
Can you post a "packet debug" of the line in question? It might be that it has embedded colour codes and spans two styles.

- Nick Gammon

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

Posted by Tesagk   (51 posts)  [Biography] bio
Date Reply #39 on Mon 26 Sep 2016 08:49 PM (UTC)

Amended on Mon 26 Sep 2016 09:39 PM (UTC) by Tesagk

Message
Nick Gammon said:

Can you post a "packet debug" of the line in question? It might be that it has embedded colour codes and spans two styles.


Is that an extra trace feature?

[EDIT]

Incoming packet: 61 (79 bytes) at Monday, September 26, 2016, 6:35:00 PM

[SGP - Main Glob   5b 53 47 50 20 2d 20 4d 61 69 6e 20 47 6c 6f 62
als(#6){.[1mCore   61 6c 73 28 23 36 29 7b 1b 5b 31 6d 43 6f 72 65
.[0m}<-(#21501)]   1b 5b 30 6d 7d 3c 2d 28 23 32 31 35 30 31 29 5d
 GAME> Trino Va   20 47 41 4d 45 3e 20 47 72 65 6e 69 6e 20 53 74
lve goes OOC...    72 69 6b 20 67 6f 65 73 20 4f 4f 43 2e 0d 0a

Incoming packet: 62 (2 bytes) at Monday, September 26, 2016, 6:35:09 PM

ÿñ                 ff f1

Incoming packet: 63 (78 bytes) at Monday, September 26, 2016, 6:35:10 PM

[SGP - Main Glob   5b 53 47 50 20 2d 20 4d 61 69 6e 20 47 6c 6f 62
als(#6){.[1mCore   61 6c 73 28 23 36 29 7b 1b 5b 31 6d 43 6f 72 65
.[0m}<-(#21501)]   1b 5b 30 6d 7d 3c 2d 28 23 32 31 35 30 31 29 5d
 GAME> Trino Va   20 47 41 4d 45 3e 20 47 72 65 6e 69 6e 20 53 74
lve goes IC...     72 69 6b 20 67 6f 65 73 20 49 43 2e 0d 0a

Incoming packet: 64 (2 bytes) at Monday, September 26, 2016, 6:36:09 PM

ÿñ                 ff f1

Incoming packet: 65 (2 bytes) at Monday, September 26, 2016, 6:37:09 PM

ÿñ                 ff f1
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #40 on Tue 27 Sep 2016 02:49 AM (UTC)

Amended on Tue 27 Sep 2016 02:50 AM (UTC) by Nick Gammon

Message
Quote:

Is that an extra trace feature?


It shows exactly what has arrived from the MUD. I can convert that back into a test packet which can be used with Ctrl+Shift+F12, such as:


[SGP - Main Globals(#6){\1b[1mCore\1b[0m}<-(#21501)]rik goes OOC.\0d\0a\ff\f1[SGP - Main Globals(#6){\1b[1mCore\1b[0m}<-(#21501)]rik goes IC.\0d\0a\ff\f1\ff\f1


Now, analyzing that with "tprint (styles)" we see that indeed there are multiple style runs, thus the string.gsub doesn't match:


[SGP - Main Globals(#6){Core}<-(#21501)]
1:
  "textcolour"=8454143
  "backcolour"=0
  "length"=24
  "style"=0
  "text"="[SGP - Main Globals(#6){"
2:
  "textcolour"=8454143
  "backcolour"=0
  "length"=4
  "style"=0
  "text"="Core"
3:
  "textcolour"=8454143
  "backcolour"=0
  "length"=12
  "style"=0
  "text"="}<-(#21501)]"
4:
  "textcolour"=12632256
  "backcolour"=0
  "length"=12
  "style"=0
  "text"="rik goes IC."


Funnily enough, the styles are the same, which is odd. There must be some bug in the client where it doesn't merge the styles. As a work-around you can merge them in the script before testing for spoofing:


pnp = pnp or {}
pnp.nospoof = pnp.nospoof or {}

function pnp.nospoof.gather(name, line, wildcards, styles)
    local noSpoof = string.gsub(wildcards[1], "[%^%<%$%(%)%%%.%{%}%[%]%*%+%-%?]", "%%%1")
    local outputted = false
    
    -- merge identical styles
    local i = 1
    while i < #styles do
      local s1 = styles [i]
      local s2 = styles [i + 1]
      if s1.textcolour == s2.textcolour and
         s1.backcolour == s2.backcolour and
         s1.style      == s2.style then
         -- merge this style with the next one
         s1.text = s1.text .. s2.text
         table.remove (styles, i + 1)
      else
        i = i + 1
      end -- if
    end -- while each style
        
    for k,v in ipairs(styles) do
        text = string.gsub(v.text, noSpoof, "")
        if not outputted then
          text = string.gsub (text, "^ ", "")
        end -- leading space on first output
        if #text > 0 then
          outputted = true
        end  -- if
        ColourTell(RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), text)
    end 
    
    Note()
end


That seems to give good results.

- Nick Gammon

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

Posted by Tesagk   (51 posts)  [Biography] bio
Date Reply #41 on Tue 27 Sep 2016 09:41 AM (UTC)
Message
Seems to be working. Thank you. I'll let you know if there are any additional problems.
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #42 on Tue 27 Sep 2016 10:33 PM (UTC)
Message
For future reference, I find this plugin useful:

http://www.gammon.com.au/forum/?id=9609

That lets me take a packet debug (such as the ones you supplied) and turn them back into something I can test what you are receiving. It includes the ANSI codes, newlines, MXP stuff and so on.

In your case you can test a trigger quickly without having to log onto the MUD and reproduce a certain message that might be time-consuming to obtain.

The converted text is just pasted into a "debug world output" window (Shift+Ctrl+F12).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


8,797 views.

This is page 3, subject is 3 pages long:  [Previous page]  1  2  3 

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]