-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
683 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# GameId API | ||
|
||
## minetest versions >= 5.7 | ||
|
||
simply returns `minetest.get_game_info().id` | ||
|
||
## minetest versions < 5.7 | ||
|
||
approximates the gameid value via a hardcoded table of gameid=>modname | ||
and then checks via `minetest.get_modpath()`. If it fails, it falls | ||
back to using `xcompat_unknown_gameid` as the id. See the chart in the | ||
readme for which games are supported |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Materials API | ||
|
||
consult `/src/materials/minetest.lua` at this time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Textures API | ||
|
||
consult `/src/texture/minetest.lua` at this time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
local materials_list = minetest.get_dir_list(xcompat.modpath.."/src/materials", false) | ||
local materials = {} | ||
for _, material in ipairs(materials_list) do | ||
local gameid = material:sub(1, -5) | ||
materials[gameid] = dofile(xcompat.modpath.."/src/materials/"..material) | ||
end | ||
|
||
local textures_list = minetest.get_dir_list(xcompat.modpath.."/src/textures", false) | ||
local textures = {} | ||
for _, texture in ipairs(textures_list) do | ||
local gameid = texture:sub(1, -5) | ||
textures[gameid] = dofile(xcompat.modpath.."/src/textures/"..texture) | ||
end | ||
|
||
minetest.register_chatcommand("xcompat_test_materials", { | ||
description = "Test materials", | ||
privs = {server=true}, | ||
func = function(name, _) | ||
local reference_materials = materials["minetest"] | ||
|
||
for gameid, game_materials in pairs(materials) do | ||
for material, _ in pairs(reference_materials) do | ||
if not game_materials[material] then | ||
minetest.chat_send_player(name, "Missing material: "..material.." in game: "..gameid) | ||
end | ||
end | ||
end | ||
|
||
minetest.chat_send_player(name, "Materials test complete") | ||
end | ||
}) | ||
|
||
--WARNING: only handles top level of table currently | ||
--TODO: handle nested tables | ||
minetest.register_chatcommand("xcompat_test_textures", { | ||
description = "Test textures", | ||
privs = {server=true}, | ||
func = function(name, _) | ||
local reference_textures = textures["xcompat_agnostic"] | ||
|
||
for gameid, game_textures in pairs(textures) do | ||
for texture, _ in pairs(reference_textures) do | ||
if not game_textures[texture] then | ||
minetest.chat_send_player(name, "Missing texture: "..texture.." in game: "..gameid) | ||
end | ||
end | ||
end | ||
|
||
minetest.chat_send_player(name, "Textures test complete") | ||
end | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
local game_alias = { | ||
mineclone2 = "mineclonia", | ||
} | ||
|
||
local game_modnames = { | ||
mineclonia = "mcl_core", | ||
farlands_reloaded = "fl_core", | ||
minetest = "default", | ||
hades = "hades_core", | ||
exile = "exile_env_sounds", | ||
ksurvive2 = "ks_metals", | ||
} | ||
|
||
local gameid = "xcompat_unknown_gameid" | ||
|
||
if type(minetest.get_game_info) == "function" then | ||
gameid = minetest.get_game_info().id | ||
else | ||
for game, modname in pairs(game_modnames) do | ||
if minetest.get_modpath(modname) then | ||
gameid = game | ||
break | ||
end | ||
end | ||
end | ||
|
||
--for games that are similar/derviatives of other games | ||
if game_alias[gameid] then gameid = game_alias[gameid] end | ||
|
||
return gameid |
Oops, something went wrong.