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