Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ SendImmediate eats escaped carriage return

SendImmediate eats escaped carriage return

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


Posted by Boxknife   (19 posts)  Bio
Date Mon 24 Nov 2008 09:41 PM (UTC)

Amended on Mon 24 Nov 2008 09:42 PM (UTC) by Boxknife

Message
I'm trying to send this text to the MUD through a script.

prompt %h/%m/%v/%t %A, %w, %O, %L>\n


In the trigger, I'm calling SendImmediate like this:

SendImmediate("prompt \%h\/\%m\/\%v\/\%t \%A\, \%w\, \%O\, \%L\> \\n")

Whatever I do, it gobbles up the \n. How do I get it to send that \n as is?

(Alright, it's a newline, not a carriage return. My bad)
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #1 on Mon 24 Nov 2008 10:10 PM (UTC)
Message
I tried your code, bar a minor modification (say instead of prompt) so my mud would show me what I sent, and even that showed me a pretty (literal) \n at the end. I can't seem to reproduce your problem, so are you sure you aren't doing something else that might be causing the problem?
Top

Posted by Boxknife   (19 posts)  Bio
Date Reply #2 on Mon 24 Nov 2008 10:30 PM (UTC)

Amended on Mon 24 Nov 2008 10:32 PM (UTC) by Boxknife

Message
This is my script. Everything else works, and everything -but- the newline is sent for the prompt.

<triggers>
<trigger
custom_colour="5"
enabled="y"
group="Logging Triggers"
lines_to_match="2"
match="(Welcome to the world of Zalanthas|Reconnected.).*?"
regexp="y"
send_to="12"
sequence="100"
>
<send>OpenLog("",true)
ColourNote("red","black","Now logging.")
SendImmediate("prompt \%h\/\%m\/\%v\/\%t \%A\, \%w\, \%O\, \%L\&gt; \\n")</send>
</trigger>
</triggers>



When I try putting a character after the \\n, like $, the character $ will show up on the next line. Apparently, it's not escaping that \\n for some reason.
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #3 on Mon 24 Nov 2008 11:49 PM (UTC)
Message
Clearly the Send To Script function has a little deficiency of sorts, for a reason I'm not too sure about. Either way, experimentation showed that you don't need one \, or two \\, or even three \\\... no, you need FOUR \\\\ to make the \n come out properly when using the Send to Script option.

You can most likely avoid this when using a proper scriptfile, though. (The only way to script if you ask me, but everyone has their own preference. ^^)

I hope this will make it work for you.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 26 Nov 2008 04:32 AM (UTC)
Message
Send to script converts \\ to \, and then inside a quoted string Lua converts \\ to \, so four backslashes are necessary, inside send-to-script, to get one.

- Nick Gammon

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


13,698 views.

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

Go to topic:           Search the forum


[Go to top] top

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