diff --git a/.luacheckrc b/.luacheckrc index 7bbe2a8..1358636 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,5 +1,22 @@ std = { globals = { + prismaDebugLuacheckGenerator = { + fields = { + luaCheckGlobalsTable = {}, + customEncode = {}, + cleanUp = {} + } + }, + prismaDebugLog = { + fields = { + tableTree = {}, + detailedTableTree = {}, + tableList = {}, + info = {}, + warn = {}, + error = {} + } + }, thirdpartyenabled = {}, tech = {}, sl = { @@ -292,23 +309,8 @@ std = { }, debug = { fields = { - log = { - fields = { - tableTree = {}, - detailedTableTree = {}, - tableList = {}, - info = {}, - warn = {}, - error = {} - } - }, - luacheckgenerator = { - fields = { - luaCheckGlobalsTable = {}, - customEncode = {}, - cleanUp = {} - } - }, + log = {}, + luacheckgenerator = {}, enabled = {} } } diff --git a/Prisma/prisma/core/generic.lua b/Prisma/prisma/core/generic.lua index 5e162d4..bbe69cf 100644 --- a/Prisma/prisma/core/generic.lua +++ b/Prisma/prisma/core/generic.lua @@ -23,15 +23,15 @@ function update(...) localAnimator = string.prisma.localAnimator; elseif firstSuccessUpdate then - string.prisma.debug.log.info("Got the LocalAnimator!"); + prismaDebugLog.info("Got the LocalAnimator!"); firstSuccessUpdate = false; - string.prisma.debug.log.detailedTableTree(_ENV, ""); + -- prismaDebugLog.detailedTableTree(_ENV, ""); - local resultTable = string.prisma.debug.luacheckgenerator.luaCheckGlobalsTable(_ENV) - local resultString = string.prisma.debug.luacheckgenerator.customEncode(resultTable) - resultString = string.prisma.debug.luacheckgenerator.cleanUp(resultString) + local resultTable = prismaDebugLuacheckGenerator.luaCheckGlobalsTable(_ENV) + local resultString = prismaDebugLuacheckGenerator.customEncode(resultTable) + resultString = prismaDebugLuacheckGenerator.cleanUp(resultString) if resultString then sb.logInfo("%s", resultString) end diff --git a/Prisma/prisma/debug/log.lua b/Prisma/prisma/debug/log.lua index 7379736..cd857e4 100644 --- a/Prisma/prisma/debug/log.lua +++ b/Prisma/prisma/debug/log.lua @@ -2,19 +2,21 @@ string.prisma = string.prisma or {}; string.prisma.debug = string.prisma.debug or {}; string.prisma.debug.log = {}; -function string.prisma.debug.log.tableList(node, displayString) +prismaDebugLog = {} + +function prismaDebugLog.tableList(node, displayString) if not string.prisma.debug.enabled then return; end if type(node) == "table" then for nodeName, nodeType in pairs(node) do sb.logInfo("%s%s : %s", displayString, nodeName, type(nodeType)); - string.prisma.debug.log.tableList(nodeType, displayString .. nodeName .. "."); + prismaDebugLog.tableList(nodeType, displayString .. nodeName .. "."); end end end -function string.prisma.debug.log.tableTree(node, displayString) +function prismaDebugLog.tableTree(node, displayString) if not string.prisma.debug.enabled then return; end @@ -25,12 +27,12 @@ function string.prisma.debug.log.tableTree(node, displayString) arrow = "└>"; end sb.logInfo("%s%s %s : %s", displayString, arrow, nodeName, type(nodeType)); - string.prisma.debug.log.tableTree(nodeType, displayString .. " "); + prismaDebugLog.tableTree(nodeType, displayString .. " "); end end end -function string.prisma.debug.log.detailedTableTree(node, displayString) +function prismaDebugLog.detailedTableTree(node, displayString) if not string.prisma.debug.enabled then return; end @@ -44,12 +46,12 @@ function string.prisma.debug.log.detailedTableTree(node, displayString) if type(nodeType) ~= "table" and type(nodeType) ~= "function" then sb.logInfo("%s %s", displayString, nodeType); end - string.prisma.debug.log.detailedTableTree(nodeType, displayString .. " "); + prismaDebugLog.detailedTableTree(nodeType, displayString .. " "); end end end -function string.prisma.debug.log.info(message, title) +function prismaDebugLog.info(message, title) if not string.prisma.debug.enabled then return; end @@ -58,7 +60,7 @@ function string.prisma.debug.log.info(message, title) sb.logInfo("\n[%s] %s", title, message); end -function string.prisma.debug.log.warn(message, title) +function prismaDebugLog.warn(message, title) if not string.prisma.debug.enabled then return; end @@ -67,7 +69,7 @@ function string.prisma.debug.log.warn(message, title) sb.logWarn("\n[%s] %s", title, message); end -function string.prisma.debug.log.error(message, title) +function prismaDebugLog.error(message, title) if not string.prisma.debug.enabled then return; end @@ -76,3 +78,6 @@ function string.prisma.debug.log.error(message, title) sb.logError("\n[%s] %s", title, message); end + +--- Export the functions for 3rd parties to use without the possibility of changing the original code +string.prisma.debug.log = prismaDebugLog; diff --git a/Prisma/prisma/debug/luacheckgenerator.lua b/Prisma/prisma/debug/luacheckgenerator.lua index 0a1961a..5d2af62 100644 --- a/Prisma/prisma/debug/luacheckgenerator.lua +++ b/Prisma/prisma/debug/luacheckgenerator.lua @@ -2,7 +2,9 @@ string.prisma = string.prisma or {}; string.prisma.debug = string.prisma.debug or {}; string.prisma.debug.luacheckgenerator = {}; -function string.prisma.debug.luacheckgenerator.luaCheckGlobalsTable(node) +prismaDebugLuacheckGenerator = {}; + +function prismaDebugLuacheckGenerator.luaCheckGlobalsTable(node) if not string.prisma.debug.enabled then return; end @@ -12,7 +14,7 @@ function string.prisma.debug.luacheckgenerator.luaCheckGlobalsTable(node) if type(node) == "table" then for nodeName, nodeValue in pairs(node) do if type(nodeValue) == "table" then - resultTable[nodeName] = string.prisma.debug.luacheckgenerator.luaCheckGlobalsTable(nodeValue) + resultTable[nodeName] = prismaDebugLuacheckGenerator.luaCheckGlobalsTable(nodeValue) elseif type(nodeValue) == "function" then resultTable[nodeName] = {} -- Replace functions with an empty table else @@ -24,7 +26,7 @@ function string.prisma.debug.luacheckgenerator.luaCheckGlobalsTable(node) return resultTable end -function string.prisma.debug.luacheckgenerator.customEncode(value) +function prismaDebugLuacheckGenerator.customEncode(value) if not string.prisma.debug.enabled then return; end @@ -33,7 +35,7 @@ function string.prisma.debug.luacheckgenerator.customEncode(value) local elements = {} for k, v in pairs(value) do local key = type(k) == "string" and string.format('"%s": ', k) or "" - table.insert(elements, key .. string.prisma.debug.luacheckgenerator.customEncode(v)) + table.insert(elements, key .. prismaDebugLuacheckGenerator.customEncode(v)) end return "{ fields: {" .. table.concat(elements, ", ") .. "}}" elseif type(value) == "string" then @@ -45,7 +47,7 @@ function string.prisma.debug.luacheckgenerator.customEncode(value) end end -function string.prisma.debug.luacheckgenerator.cleanUp(input) +function prismaDebugLuacheckGenerator.cleanUp(input) if not string.prisma.debug.enabled then return; end @@ -57,3 +59,7 @@ function string.prisma.debug.luacheckgenerator.cleanUp(input) output = output:gsub('" =', ' =') return output end + + +--- Export the functions for 3rd parties to use without the possibility of changing the original code +string.prisma.debug.luacheckgenerator = prismaDebugLuacheckGenerator; \ No newline at end of file