local printf_console = nil function printf( fmt, ... ) if string.find( command_line(), "-printf", 0, true ) == nil then printf = printf_nil end if fmt == nil then return -- formatless end if printf_console == nil then if get_console ~= nil then printf_console = get_console() end return end if printf_console == nil then return -- can't get console end printf = printf_main printf_main( fmt, ... ) end function printf_main( fmt, ...) local c = select( "#", ... ) if c <= 0 then -- nothing to format printf_console:execute( ":" .. string.gsub( fmt, " ", "\160" ) ) else printf_console:execute( ":" .. string.gsub( string.format( fmt, ... ), " ", "\160" ) ) end end function printf_nil( ... ) end