From 94a62f8c319d69128e6ff8f5330516f2d975ec05 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Mon, 27 Nov 2023 19:32:52 -0500 Subject: [PATCH] #377 switched to using ... for vararg --- initenv.lua | 2 -- scada-common/util.lua | 17 +++++------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/initenv.lua b/initenv.lua index 05ad4f6..035d84e 100644 --- a/initenv.lua +++ b/initenv.lua @@ -2,9 +2,7 @@ return { -- initialize booted environment init_env = function () local _require, _env = require("cc.require"), setmetatable({}, { __index = _ENV }) - -- overwrite require/package globals require, package = _require.make(_env, "/") - -- reset terminal term.clear(); term.setCursorPos(1, 1) end } diff --git a/scada-common/util.lua b/scada-common/util.lua index 8257a2d..d386bd3 100644 --- a/scada-common/util.lua +++ b/scada-common/util.lua @@ -16,13 +16,13 @@ local type = type local t_concat = table.concat local t_insert = table.insert -local t_unpack = table.unpack +local t_pack = table.pack ---@class util local util = {} -- scada-common version -util.version = "1.1.9" +util.version = "1.1.10" util.TICK_TIME_S = 0.05 util.TICK_TIME_MS = 50 @@ -104,17 +104,13 @@ end ---@return table lines function util.strwrap(str, limit) return cc_strings.wrap(str, limit) end --- luacheck: no unused args - -- concatenation with built-in to string ---@nodiscard ---@vararg any ---@return string ----@diagnostic disable-next-line: unused-vararg function util.concat(...) - local strings = {} ----@diagnostic disable-next-line: undefined-field - for i = 1, arg.n do strings[i] = util.strval(arg[i]) end + local args, strings = t_pack(...), {} + for i = 1, args.n do strings[i] = util.strval(args[i]) end return t_concat(strings) end @@ -125,10 +121,7 @@ util.c = util.concat ---@nodiscard ---@param format string ---@vararg any ----@diagnostic disable-next-line: unused-vararg -function util.sprintf(format, ...) return string.format(format, t_unpack(arg)) end - --- luacheck: unused args +function util.sprintf(format, ...) return string.format(format, ...) end -- format a number string with commas as the thousands separator
-- subtracts from spaces at the start if present for each comma used