From f97ca9825ea6e043aa9b254dc0d1c89ca4251be7 Mon Sep 17 00:00:00 2001 From: Jesse van den Kieboom Date: Tue, 15 Nov 2005 12:06:33 +0000 Subject: [PATCH] Added sendfile --- scripts/misc.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/misc.rb b/scripts/misc.rb index 0b38a41..d05580c 100644 --- a/scripts/misc.rb +++ b/scripts/misc.rb @@ -24,6 +24,7 @@ def register_functions $scripts.register("open", "use: /open \nopen a world") $scripts.register("sendall", "use: /sendall \nsends to all currently connected worlds") + $scripts.register("sendfile", "use: /sendfile \nsends contents of to world") end def open(argstr) @@ -37,3 +38,15 @@ def sendall(argstr) end } end + +def sendfile(argstr) + if FileTest.exists?(argstr) + lines = IO.readlines(argstr) + $world.writeln("Sending contents of file #{argstr} (#{lines.length})") + lines.each do |line| + $world.sendln(line.chomp) + end + else + $world.writeln("File #{argstr} does not exist!") + end +end