Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Provide real game id in addition to compatible base game id #30

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ xcompat = {
modpath = modpath,
}

xcompat.gameid = dofile(modpath .. "/src/gameid.lua")
xcompat.gameid, xcompat.real_gameid = dofile(modpath .. "/src/gameid.lua")
xcompat.utilities = dofile(modpath .. "/src/utilities.lua")

xcompat.sounds = dofile(modpath .. "/src/sounds.lua")
Expand Down
26 changes: 15 additions & 11 deletions src/gameid.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
local game_alias = {
local supported_games = {
mineclone2 = "mineclonia",
mineclonia = "mineclonia",
farlands_reloaded = "farlands_reloaded",
minetest = "minetest",
hades_revisited = "hades",
Exile = "exile",
ksurvive2 = "ksurvive2",
}

local game_modnames = {
Expand All @@ -11,11 +17,15 @@ local game_modnames = {
ksurvive2 = "ks_metals",
}

local gameid = "xcompat_unknown_gameid"
local real_gameid = "xcompat_unknown_gameid"

if type(minetest.get_game_info) == "function" then
gameid = minetest.get_game_info().id
else
real_gameid = minetest.get_game_info().id
end

local gameid = supported_games[real_gameid]

if not gameid then
for game, modname in pairs(game_modnames) do
if minetest.get_modpath(modname) then
gameid = game
Expand All @@ -24,10 +34,4 @@ else
end
end

--for games that are similar/derviatives of other games
if game_alias[gameid] then gameid = game_alias[gameid] end

--while minetest game derviates are not supported, we can still try to detect them
if minetest.get_modpath("default") then gameid = "minetest" end

return gameid
return gameid or "xcompat_unknown_gameid", real_gameid