TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

strip line feed code from GMCP

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help
View previous topic :: View next topic  
Author Message
wstopek



Joined: 27 Dec 2012
Posts: 22

PostPosted: Mon Jul 03, 2017 4:42 am    Post subject: strip line feed code from GMCP Reply with quote

My GMCP event sends me raw json data(%1) like this:
Code:

gmcp_msgs {"text":"Izba sypialna.\n","type":"room.short"}

but under %0 I've got parsed:
Code:

{text}{Izba sypialna.
}{type}{room.short}

Can I get rid of this line feed somehow?
Back to top
View user's profile Send private message
moire



Joined: 29 Jan 2012
Posts: 24

PostPosted: Mon Jul 03, 2017 9:56 am    Post subject: Reply with quote

Yes, you can do it!
Code:

#var test  {test.\nnewline}
#OK. VARIABLE {test} HAS BEEN SET TO {test.\nnewline}.
#showme $test
test.
newline
#function striplf {#var {result} {%0}; #replace {result} {\\n} {};}
#OK. FUNCTION {striplf} HAS BEEN SET TO {#var {result} {%0}; #replace {result} {\\n} {};}.
#showme @striplf{$test}
test.newline

Note the double slash "\\n" in the striplf function.
Perhaps someone can explain why it is needed.
Also note that by using the variable name "result" in a function you do not need to use #return {...}
Back to top
View user's profile Send private message
wstopek



Joined: 27 Dec 2012
Posts: 22

PostPosted: Mon Jul 03, 2017 10:27 am    Post subject: Reply with quote

It won't help because I don't want parse raw json format:
Code:

{"text":"Izba sypialna.\n","type":"room.short"}

In my case \n is already replaced by space to new line:
Code:

{text}{Izba sypialna.
}{type}{room.short}
Back to top
View user's profile Send private message
dorian



Joined: 29 Jul 2012
Posts: 66

PostPosted: Mon Jul 03, 2017 12:35 pm    Post subject: Reply with quote

have you try

Code:
#line strip {#var target $orgin}


?
not sure if that works
Back to top
View user's profile Send private message
wstopek



Joined: 27 Dec 2012
Posts: 22

PostPosted: Mon Jul 03, 2017 3:43 pm    Post subject: Reply with quote

Edit:
Finaly I solved it this way:
Code:

#event {IAC SB GMCP gmcp_msgs IAC SE}
{
#local {test} {%0};
#local {test2} {$test[text]};
#replace {test2} {\\n} {};
#sh {$test2}
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group