48 lines
1.0 KiB
Lua
48 lines
1.0 KiB
Lua
require "common.globals"
|
|
require "api.logging"
|
|
|
|
---@note setup code from: https://stackoverflow.com/a/30960054
|
|
local BinaryFormat = package.cpath:match("%?%.(%a+)")
|
|
DetailedLog("BinaryFormat: " .. BinaryFormat, game.LOGGER_DEBUG)
|
|
|
|
if BinaryFormat == "dll" then
|
|
function os.name()
|
|
return "Windows"
|
|
end
|
|
elseif BinaryFormat == "so" then
|
|
function os.name()
|
|
return "Linux"
|
|
end
|
|
elseif BinaryFormat == "dylib" then
|
|
function os.name()
|
|
return "MacOS"
|
|
end
|
|
else
|
|
DetailedLog("Could not identify binary format", game.LOGGER_WARNING)
|
|
function os.name()
|
|
return nil
|
|
end
|
|
end
|
|
|
|
BinaryFormat = nil
|
|
|
|
Platform = {
|
|
WINDOWS = "Windows",
|
|
LINUX = "Linux",
|
|
MACOS = "MacOS"
|
|
}
|
|
|
|
---Get OS platform lua is running on
|
|
function GetPlatform()
|
|
return os.name()
|
|
end
|
|
|
|
---Merge base module table with implementation table, overwriting base
|
|
---@param base any
|
|
---@param implementation any
|
|
function MergeModules(base, implementation)
|
|
for key, value in pairs(implementation) do
|
|
base[key] = value
|
|
end
|
|
end
|