diff options
author | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2024-03-25 20:47:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-25 20:47:35 +0200 |
commit | 6d3226ea5a680966dfb931c396691de43536fd88 (patch) | |
tree | 551a3a455445824db437fe42e9726591935baa9c /indra/newview/scripts/lua/printf.lua | |
parent | 7f39a5bb109338b201c9cd0d3a40baac2b2e4fc1 (diff) | |
parent | 2eb6901c7c9ae87a588d99399e4b41640e4c4881 (diff) |
Merge branch 'release/luau-scripting' into lua-keystroke
Diffstat (limited to 'indra/newview/scripts/lua/printf.lua')
-rw-r--r-- | indra/newview/scripts/lua/printf.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/printf.lua b/indra/newview/scripts/lua/printf.lua new file mode 100644 index 0000000000..584cd4f391 --- /dev/null +++ b/indra/newview/scripts/lua/printf.lua @@ -0,0 +1,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 |