Added sendfile

This commit is contained in:
Jesse van den Kieboom 2005-11-15 12:06:33 +00:00
parent 612b411f82
commit f97ca9825e
1 changed files with 13 additions and 0 deletions

View File

@ -24,6 +24,7 @@
def register_functions
$scripts.register("open", "use: /open <worldname>\nopen a world")
$scripts.register("sendall", "use: /sendall <some>\nsends <some> to all currently connected worlds")
$scripts.register("sendfile", "use: /sendfile <file-on-disk>\nsends contents of <file-on-disk> 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