From c5e2668577bee2a536d032f133f4dec60e86e4dd Mon Sep 17 00:00:00 2001 From: lonaasan Date: Tue, 22 Oct 2024 22:46:00 +0200 Subject: [PATCH] added compatibility-check and new log design --- .luacheckrc | 17 +++++++++++++++ Prisma/_metadata | 9 ++++---- Prisma/prisma/compatibility/check.lua | 30 +++++++++++++++++++++++++++ Prisma/prisma/core/generic.lua | 6 ++++++ Prisma/prisma/debug/log.lua | 6 +++--- 5 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 Prisma/prisma/compatibility/check.lua diff --git a/.luacheckrc b/.luacheckrc index d7e358c..134e46e 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,6 +1,7 @@ std = { globals = { std = {}, + neon = {}, prismaAPIStorage = {}, prismaAPI = { fields = { @@ -25,6 +26,12 @@ std = { error = {} } }, + prismaCompatibilityCheck = { + fields = { + IsNeon = {}, + IsOpenStarbound = {} + } + }, thirdpartyenabled = {}, tech = {}, sl = { @@ -315,6 +322,16 @@ std = { addLightSource = {} } }, + compatibility = { + fields = { + check = { + fields = { + IsNeon = {}, + IsOpenStarbound = {} + } + } + } + }, debug = { fields = { log = { diff --git a/Prisma/_metadata b/Prisma/_metadata index 19823c6..6e7abef 100644 --- a/Prisma/_metadata +++ b/Prisma/_metadata @@ -1,8 +1,9 @@ { "author" : "^#00ffff;L^#25dbff;o^#49b7ff;n^#6e92ff;a^#926eff;a^#b749ff;s^#db25ff;a^#ff00ff;n^reset;", - "description" : "Prisma Core Multiplayer compatible", - "friendlyName" : "Prisma Core", - "name" : "prisma core", + "description" : "^#ffa3a3;P^#ffffa3;r^#a3ffa3;i^#a3ffff;s^#a3a3ff;m^#ffa3ff;a^reset; Modding API\n\nMultiplayer compatible\n\nSupport for Vanilla, Neon, OpenStarbound and OpenSB-derivatives\n\nGithub: https://github.com/Lonaasan/Prisma", + "friendlyName" : "^#ffa3a3;P^#ffffa3;r^#a3ffa3;i^#a3ffff;s^#a3a3ff;m^#ffa3ff;a^reset;", + "name" : "prisma", "priority" : 100, "version" : "0.0.0.1" -} \ No newline at end of file +} + diff --git a/Prisma/prisma/compatibility/check.lua b/Prisma/prisma/compatibility/check.lua new file mode 100644 index 0000000..d5dc290 --- /dev/null +++ b/Prisma/prisma/compatibility/check.lua @@ -0,0 +1,30 @@ +---Prisma Debug Logger | https://github.com/Lonaasan/Prisma/blob/main/Prisma/prisma/debug/log.lua +---Author: Lonaasan + +string.prisma = string.prisma or {}; +string.prisma.compatibility = string.prisma.compatibility or {}; +string.prisma.compatibility.check = {}; + +prismaCompatibilityCheck = {} + + +---Check we are running with Neon++ +---@return boolean +function prismaCompatibilityCheck.IsNeon() + if neon then + return true; + else + return false; + end +end + +---Check we are running in OpenStarbound +---@return boolean +function prismaCompatibilityCheck.IsOpenStarbound() + error("Not implemented yet", 2); + return false; +end + + +--- Export the functions for 3rd parties to use without the possibility of changing the original code +string.prisma.compatibility.check = prismaCompatibilityCheck; \ No newline at end of file diff --git a/Prisma/prisma/core/generic.lua b/Prisma/prisma/core/generic.lua index 0bf03f9..d36e510 100644 --- a/Prisma/prisma/core/generic.lua +++ b/Prisma/prisma/core/generic.lua @@ -4,6 +4,7 @@ require("/prisma/debug/log.lua"); require("/prisma/debug/luacheck.lua"); require("/prisma/api/api.lua"); +require("/prisma/compatibility/check.lua"); local _init = init or function() end; @@ -34,6 +35,11 @@ function update(...) if not localAnimator then localAnimator = string.prisma.localAnimator; elseif firstSuccessUpdate then + if prismaCompatibilityCheck.IsNeon() then + prismaDebugLog.info("We are running with Neon++!"); + else + prismaDebugLog.info("We are not running with Neon++!"); + end prismaDebugLog.info("Got the LocalAnimator!"); diff --git a/Prisma/prisma/debug/log.lua b/Prisma/prisma/debug/log.lua index cceabf3..fece649 100644 --- a/Prisma/prisma/debug/log.lua +++ b/Prisma/prisma/debug/log.lua @@ -76,7 +76,7 @@ function prismaDebugLog.info(message, title) end title = title or " PRISMA "; - sb.logInfo("\n[%s] %s", title, message); + sb.logInfo("[%s] %s", title, message); end ---Logs a warning message with a title @@ -89,7 +89,7 @@ function prismaDebugLog.warn(message, title) end title = title or " PRISMA "; - sb.logWarn("\n[%s] %s", title, message); + sb.logWarn("[%s] %s", title, message); end ---Logs an error message with a title @@ -102,7 +102,7 @@ function prismaDebugLog.error(message, title) end title = title or " PRISMA "; - sb.logError("\n[%s] %s", title, message); + sb.logError("[%s] %s", title, message); end