mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
don't print brackets in util.strval if metatable __tostring is present
This commit is contained in:
parent
0f5ae9a756
commit
55dab6d675
@ -65,7 +65,8 @@ end
|
|||||||
---@return string
|
---@return string
|
||||||
function util.strval(val)
|
function util.strval(val)
|
||||||
local t = type(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) .. "]"
|
return "[" .. tostring(val) .. "]"
|
||||||
else
|
else
|
||||||
return tostring(val)
|
return tostring(val)
|
||||||
|
Loading…
Reference in New Issue
Block a user