Added sendfile
This commit is contained in:
parent
612b411f82
commit
f97ca9825e
|
@ -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
|
||||
|
|
Reference in New Issue