blob: 584cd4f391826bca25f986ab37b40d738034729d (
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(...)
-- 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(table.unpack(args)))
end
return printf
|