Skip to content

Commit

Permalink
added compatibility-check and new log design
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonaasan committed Oct 22, 2024
1 parent 6eb8b27 commit c5e2668
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 7 deletions.
17 changes: 17 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
std = {
globals = {
std = {},
neon = {},
prismaAPIStorage = {},
prismaAPI = {
fields = {
Expand All @@ -25,6 +26,12 @@ std = {
error = {}
}
},
prismaCompatibilityCheck = {
fields = {
IsNeon = {},
IsOpenStarbound = {}
}
},
thirdpartyenabled = {},
tech = {},
sl = {
Expand Down Expand Up @@ -315,6 +322,16 @@ std = {
addLightSource = {}
}
},
compatibility = {
fields = {
check = {
fields = {
IsNeon = {},
IsOpenStarbound = {}
}
}
}
},
debug = {
fields = {
log = {
Expand Down
9 changes: 5 additions & 4 deletions Prisma/_metadata
Original file line number Diff line number Diff line change
@@ -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"
}
}

30 changes: 30 additions & 0 deletions Prisma/prisma/compatibility/check.lua
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 6 additions & 0 deletions Prisma/prisma/core/generic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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!");

Expand Down
6 changes: 3 additions & 3 deletions Prisma/prisma/debug/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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


Expand Down

0 comments on commit c5e2668

Please sign in to comment.