SendImmediate eats escaped carriage return

Posted by Boxknife on Mon 24 Nov 2008 09:41 PM — 5 posts, 17,898 views.

#0
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)
Amended on Mon 24 Nov 2008 09:42 PM by Boxknife
Netherlands #1
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?
#2
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.
Amended on Mon 24 Nov 2008 10:32 PM by Boxknife
Netherlands #3
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.
Australia Forum Administrator #4
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.