blob: e84b2024dfcd5be28443ae307319d90b8fbacecb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
-- printf(...) is short for print(string.format(...))
local inspect = require 'inspect'
local function printf(format, ...)
-- string.format() only handles numbers and strings.
-- Convert anything else to string using the inspect module.
local args = {}
for _, arg in pairs(table.pack(...)) do
if type(arg) == 'number' or type(arg) == 'string' then
table.insert(args, arg)
else
table.insert(args, inspect(arg))
end
end
print(string.format(format, table.unpack(args)))
end
return printf
|