From 0115bc8dca4a82a080960c94e7aed1e6cfb72081 Mon Sep 17 00:00:00 2001 From: "Wilma456 (Jakob0815)" Date: Mon, 11 Sep 2017 15:47:30 +0200 Subject: [PATCH] Make io.write() accept multiple args This is just to bring the io API from CC close the the io API from normal lua, which accept multiple args for io.write(). --- .../assets/computercraft/lua/rom/apis/io.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/io.lua b/src/main/resources/assets/computercraft/lua/rom/apis/io.lua index 4667bf50d..0352ba64a 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/io.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/io.lua @@ -23,8 +23,10 @@ local g_defaultOutput = { bClosed = false, close = function( self ) end, - write = function( self, _sText ) - _G.write( _sText ) + write = function( self, ... ) + for k, v in ipairs( { ... } ) do + _G.write( v ) + end end, flush = function( self ) end, @@ -115,8 +117,10 @@ function open( _sPath, _sMode ) file.close() self.bClosed = true end, - write = function( self, _sText ) - file.write( _sText ) + write = function( self, ... ) + for k, v in ipairs( { ... } ) do + file.write( v ) + end end, flush = function( self ) file.flush() @@ -144,8 +148,10 @@ function open( _sPath, _sMode ) file.close() self.bClosed = true end, - write = function( self, _number ) - file.write( _number ) + write = function( self, ... ) + for k, v in ipairs( { ... } ) do + file.write( v ) + end end, flush = function( self ) file.flush()