Amended on Sun 18 Sep 2005 06:44 AM (UTC) by Nick Gammon
Message
For a start, MUSHclient has that ability built in.
See the Input menu -> Send File.
Assuming you want to do it via scripting, you can do it quickly and shortly using Lua. This alias below assumes you have the Lua language selected as your scripting language. If not, just make a plugin with it in. When you type "sendfile" it will then send the contents of file "test.txt" to the MUD. You may want to add a pathname to it, or maybe put the filename as an argument to the alias.
<aliases>
<alias
match="sendfile"
enabled="y"
send_to="12"
sequence="100"
>
<send>
do
local f = assert (io.open ("test.txt", "r"))
local t = f:read ("*all") -- read file in
f:close ()
Send (t) -- send to MUD
end
</send>
</alias>
</aliases>
This example raises a script assertion if the file cannot be opened. You could make it neater by displaying a message in red, for instance.
You might also use SendNoEcho rather than Send to stop the file from being echoed in the output window.
Yes, you can read a file and send the contents (line-by-line) to the MU*.
I would put something like the code below in my script file (Perl):
sub sendFile2PlanEditor( $$$ ) {
# We don't care about the 1st two arguments so we discard them and save the 3rd arg.
my ( undef, undef, $aref_args ) = @_;
my $fileName = @{$aref_args}[0];
# Open the file or show a nice error message.
if ( open( IN, '<' . $fileName ) ) {
# If you need to send some command to initiate the .plan editor you do it like this...
# $world->SendImmediate( 'planeditor' );
# If you need to send a special character at the beginning
# of each line (like a - or a = or something)...
my $preStr = '';
# Send the text...line by line...
while ( <IN> ) {
# Remove the newline.
chomp;
# Send it allready!!
$world->SendImmediate( $preStr . $_ );
}
close( IN );
# If you need to send a command to close the edit you do it here...
# $world->SendImmediate( '.' );
} else {
$world->ColourNote( '#FFFF00', '#FF0000', "#ERROR: Unable to open file - $!" );
}
}
I'm looking for a way to send the contents of a file to the mud. Is this possible? I would be very useful for uploading edited textfiles without having to send it as one long line.
Example:
I have an alias .plan (displayed in finger information) on the mud that I want to update with new content.
I want to be able to do something like 'alias .plan <command to read file> or something that would accomplish that.
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.