From 55dab6d675188c6228f14f222eb638c8a50636bf Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 6 Jun 2023 19:41:55 -0400 Subject: [PATCH] don't print brackets in util.strval if metatable __tostring is present --- scada-common/util.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scada-common/util.lua b/scada-common/util.lua index e13d6bb..99f62a6 100644 --- a/scada-common/util.lua +++ b/scada-common/util.lua @@ -65,7 +65,8 @@ end ---@return string function util.strval(val) local t = type(val) - if t == "table" or t == "function" then + -- this depends on Lua short-circuiting the or check for metatables (note: metatables won't have metatables) + if (t == "table" and (getmetatable(val) == nil or getmetatable(val).__tostring == nil)) or t == "function" then return "[" .. tostring(val) .. "]" else return tostring(val)