Can I get the raw data sent from server

Post Reply
zhenzh
Posts: 64
Joined: Fri Apr 17, 2020 2:23 am

Can I get the raw data sent from server

Post by zhenzh »

I'd like to process original data sent from mud server which should including ANSI color code, is there a method in mudlet provided?
Also, if it's possible, is it a method to print such raw data to screen with color code auto translated by mudlet?

zhenzh
Posts: 64
Joined: Fri Apr 17, 2020 2:23 am

Re: Can I get the raw data sent from server

Post by zhenzh »

Here's the example raw data I can received from tintin++:
BB2F7ED7-A229-4FE4-9AD0-B4BF34C51C15.jpg
BB2F7ED7-A229-4FE4-9AD0-B4BF34C51C15.jpg (34.1 KiB) Viewed 4945 times
^[[1;32mEnter your character's ^[[1;31mname^[[1;32m, or type ^[[1;31mnew^[[1;32m: Illegal name, try another.

User avatar
Vadi
Posts: 5005
Joined: Sat Mar 14, 2009 3:13 pm

Re: Can I get the raw data sent from server

Post by Vadi »

Yes on the latter, you can use https://wiki.mudlet.org/w/Manual:Lua_Fu ... ansi2decho - but Mudlet does not expose such low-level information. Typically games send it as part of OOB data. What do you need it for? You have functions available to work with the translated information to retrieve formatting details.

zhenzh
Posts: 64
Joined: Fri Apr 17, 2020 2:23 am

Re: Can I get the raw data sent from server

Post by zhenzh »

I need to process some qeusts in my playing mud, it's a colored trigger looks like this:
-328ad242544cd46f.jpg
-328ad242544cd46f.jpg (65.59 KiB) Viewed 4926 times
Players are required to recognize the number consist of special colored characters across multiple lines.
Since the color and position are not fixed, I can not use the color trigger provided by mudlet directly.
If the raw can be provided, I can easily split and gather characters by ansi code.
I'm now can only use getTextFormat() to loop each character for all lines.
While getTextFormat() may still hit some other issues. For example, the length of line to be looped. As selectSection() treats both English and Chinese character as 1, but the #line counts Chinese word as 3, it may get troubled under en/ch mixed cases.

User avatar
Vadi
Posts: 5005
Joined: Sat Mar 14, 2009 3:13 pm

Re: Can I get the raw data sent from server

Post by Vadi »

getTextFormat() is definitely the right way to go. Don't use #line - use utf8.len https://wiki.mudlet.org/w/Manual:String ... C_utf8.len.

Let me know if you run into any other issues!

zhenzh
Posts: 64
Joined: Fri Apr 17, 2020 2:23 am

Re: Can I get the raw data sent from server

Post by zhenzh »

Even utf8.len() may also count unexpected character number.
Here's a test for some special case:
841EF063-140D-4C51-8152-F0EC210FC3B0.jpg
841EF063-140D-4C51-8152-F0EC210FC3B0.jpg (119.05 KiB) Viewed 4915 times
When I count form the value of line captured by mudlet, it got a smaller number than I count the string manually copy/paste from the line

I think that should not be the problem of the utf8.len() function. It should be the string captured in line is different from the manually copied string.
May be a tab/space conversion issue?

You can also try by yourself, the mud is narutofor.us 4545, the test line is just the login line.

zhenzh
Posts: 64
Joined: Fri Apr 17, 2020 2:23 am

Re: Can I get the raw data sent from server

Post by zhenzh »

Besides, I find the getTextFormat() has an issue that the format of tha last character of a line can not be got.
Here's a test for the line contains "NarutoMUD" string:
B716262D-A2DC-4E2E-BB7E-9CA43AD99CAE.jpg
B716262D-A2DC-4E2E-BB7E-9CA43AD99CAE.jpg (30.86 KiB) Viewed 4910 times
Below are prints of format capture:
0/69 character: " " -> format: table: 0x600014fd6400
1/69 character: "/" -> format: table: 0x600014fd7dc0
2/69 character: " " -> format: table: 0x600014fd7700
3/69 character: "/" -> format: table: 0x600014fd72c0
4/69 character: "." -> format: table: 0x600014fd6fc0
5/69 character: "-" -> format: table: 0x600014fd4300
6/69 character: "'" -> format: table: 0x600014fd47c0
7/69 character: " " -> format: table: 0x600014fd4980
8/69 character: " " -> format: table: 0x600014fd7300
9/69 character: "|" -> format: table: 0x600014fd76c0
10/69 character: " " -> format: table: 0x600014fc8040
11/69 character: " " -> format: table: 0x600014fc9800
12/69 character: " " -> format: table: 0x600014fc8cc0
13/69 character: " " -> format: table: 0x600014fc8b80
14/69 character: " " -> format: table: 0x600014fca800
15/69 character: " " -> format: table: 0x600014fc9e00
16/69 character: " " -> format: table: 0x600014fc8e80
17/69 character: "'" -> format: table: 0x600014fc8480
18/69 character: "-" -> format: table: 0x600014fcbc40
19/69 character: "." -> format: table: 0x600014fca780
20/69 character: "." -> format: table: 0x600014fca5c0
21/69 character: "_" -> format: table: 0x600014fc8d80
22/69 character: "_" -> format: table: 0x600014fc8400
23/69 character: "_" -> format: table: 0x600014fc9d80
24/69 character: "_" -> format: table: 0x600014fcb980
25/69 character: "_" -> format: table: 0x600014fc9600
26/69 character: "_" -> format: table: 0x600014fcb640
27/69 character: "." -> format: table: 0x600014fc9f40
28/69 character: "." -> format: table: 0x600014fcbf00
29/69 character: "-" -> format: table: 0x600014fcea80
30/69 character: "-" -> format: table: 0x600014fcc200
31/69 character: "'" -> format: table: 0x600014fcc500
32/69 character: "'" -> format: table: 0x600014fcc800
33/69 character: " " -> format: table: 0x600014fccb00
34/69 character: " " -> format: table: 0x600014fcce00
35/69 character: " " -> format: table: 0x600014fcd140
36/69 character: " " -> format: table: 0x600014fcd480
37/69 character: " " -> format: table: 0x600014fcd7c0
38/69 character: " " -> format: table: 0x600014fcfe80
39/69 character: " " -> format: table: 0x600014fcff40
40/69 character: " " -> format: table: 0x600014fcf9c0
41/69 character: " " -> format: table: 0x600014fcfe00
42/69 character: "-" -> format: table: 0x600014fcdbc0
43/69 character: "=" -> format: table: 0x600014fceb00
44/69 character: " " -> format: table: 0x600014fcf400
45/69 character: "N" -> format: table: 0x600014fcf740
46/69 character: "a" -> format: table: 0x600014fcf500
47/69 character: "r" -> format: table: 0x600014fc2480
48/69 character: "u" -> format: table: 0x600014fc0180
49/69 character: "t" -> format: table: 0x600014fc0640
50/69 character: "o" -> format: table: 0x600014fc0940
51/69 character: "M" -> format: table: 0x600014fc0c80
52/69 character: "U" -> format: table: 0x600014fc0f80
53/69 character: "D" -> format: table: 0x600014fc1280
54/69 character: " " -> format: table: 0x600014fc1580
55/69 character: "=" -> format: table: 0x600014fc1880
56/69 character: "-" -> format: table: 0x600014fc1b80
57/69 character: " " -> format: table: 0x600014fc1e80
58/69 character: " " -> format: table: 0x600014fc2180
59/69 character: " " -> format: table: 0x600014fc24c0
60/69 character: " " -> format: table: 0x600014fc2800
61/69 character: " " -> format: table: 0x600014fc2b40
62/69 character: " " -> format: table: 0x600014fc2e80
63/69 character: " " -> format: table: 0x600014fc31c0
64/69 character: "|" -> format: table: 0x600014fc3500
65/69 character: " " -> format: table: 0x600014fc3880
66/69 character: " " -> format: table: 0x600014fc3b80
67/69 character: " " -> format: table: 0x600014fc3e80
68/69 character: "|" -> format: nil
We can see the format table saved by selectSection(68,1) and getTextFormat() is nil.

While when I do print("#") to append 1 more character for the line:
9EA544F4-4542-4F8C-9885-A5616C0C2B73.jpg
9EA544F4-4542-4F8C-9885-A5616C0C2B73.jpg (26.58 KiB) Viewed 4910 times
The format table can be got:
0/69 character: " " -> format: table: 0x60001402d4c0
1/69 character: "/" -> format: table: 0x60001402d840
2/69 character: " " -> format: table: 0x60001402dd00
3/69 character: "/" -> format: table: 0x60001402e980
4/69 character: "." -> format: table: 0x60001402ec80
5/69 character: "-" -> format: table: 0x60001402ef40
6/69 character: "'" -> format: table: 0x60001402f280
7/69 character: " " -> format: table: 0x60001402f600
8/69 character: " " -> format: table: 0x60001402f9c0
9/69 character: "|" -> format: table: 0x60001402fd40
10/69 character: " " -> format: table: 0x60001402d180
11/69 character: " " -> format: table: 0x6000140202c0
12/69 character: " " -> format: table: 0x6000140205c0
13/69 character: " " -> format: table: 0x600014020900
14/69 character: " " -> format: table: 0x600014020c00
15/69 character: " " -> format: table: 0x600014020f00
16/69 character: " " -> format: table: 0x600014021200
17/69 character: "'" -> format: table: 0x600014021500
18/69 character: "-" -> format: table: 0x600014021800
19/69 character: "." -> format: table: 0x600014021b00
20/69 character: "." -> format: table: 0x600014021e00
21/69 character: "_" -> format: table: 0x600014022100
22/69 character: "_" -> format: table: 0x600014022400
23/69 character: "_" -> format: table: 0x600014022780
24/69 character: "_" -> format: table: 0x600014022ac0
25/69 character: "_" -> format: table: 0x600014022e00
26/69 character: "_" -> format: table: 0x600014023140
27/69 character: "." -> format: table: 0x600014023480
28/69 character: "." -> format: table: 0x6000140237c0
29/69 character: "-" -> format: table: 0x600014023b00
30/69 character: "-" -> format: table: 0x600014023e40
31/69 character: "'" -> format: table: 0x600014024000
32/69 character: "'" -> format: table: 0x600014024340
33/69 character: " " -> format: table: 0x6000140246c0
34/69 character: " " -> format: table: 0x600014024a40
35/69 character: " " -> format: table: 0x600014024e00
36/69 character: " " -> format: table: 0x600014025180
37/69 character: " " -> format: table: 0x600014025540
38/69 character: " " -> format: table: 0x600014025900
39/69 character: " " -> format: table: 0x600014025c40
40/69 character: " " -> format: table: 0x600014025f80
41/69 character: " " -> format: table: 0x6000140262c0
42/69 character: "-" -> format: table: 0x600014026600
43/69 character: "=" -> format: table: 0x600014026980
44/69 character: " " -> format: table: 0x600014026c80
45/69 character: "N" -> format: table: 0x600014026f80
46/69 character: "a" -> format: table: 0x600014027280
47/69 character: "r" -> format: table: 0x600014027580
48/69 character: "u" -> format: table: 0x600014027880
49/69 character: "t" -> format: table: 0x600014027bc0
50/69 character: "o" -> format: table: 0x600014027ec0
51/69 character: "M" -> format: table: 0x60001407e780
52/69 character: "U" -> format: table: 0x60001407ed80
53/69 character: "D" -> format: table: 0x60001407f580
54/69 character: " " -> format: table: 0x60001407f380
55/69 character: "=" -> format: table: 0x60001407f6c0
56/69 character: "-" -> format: table: 0x60001407f940
57/69 character: " " -> format: table: 0x600014070440
58/69 character: " " -> format: table: 0x600014070640
59/69 character: " " -> format: table: 0x600014070200
60/69 character: " " -> format: table: 0x6000140738c0
61/69 character: " " -> format: table: 0x600014070d40
62/69 character: " " -> format: table: 0x600014070f80
63/69 character: " " -> format: table: 0x600014070140
64/69 character: "|" -> format: table: 0x600014071500
65/69 character: " " -> format: table: 0x600014071840
66/69 character: " " -> format: table: 0x600014071b40
67/69 character: " " -> format: table: 0x600014071e40
68/69 character: "|" -> format: table: 0x600014072140
69/69 character: "#" -> format: table: 0x600014072480

Post Reply