-
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
31 changed files
with
1,326 additions
and
750 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
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,13 @@ | ||
# Functions API | ||
|
||
## `can_interact_with_node(player, pos)` | ||
returns `bool` | ||
|
||
checks for the ability to interact with a node via: | ||
* if a player | ||
* owner metadata key | ||
* protection_bypass | ||
|
||
supports | ||
* minetest game default if present | ||
* else polyfill |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
name = xcompat | ||
description = Provides cross compatibility between mods and games for sounds and crafting materials. | ||
optional_depends = default, fl_stone, fl_trees, mcl_sounds, hades_sounds, ks_sounds, nodes_nature, fl_topsoil, fl_trees, mcl_core, mtt | ||
optional_depends = default, fl_stone, fl_trees, mcl_sounds, hades_sounds, ks_sounds, nodes_nature, fl_topsoil, fl_trees, mcl_core, farming, x_farming, sounds, mtt |
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,76 @@ | ||
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 | ||
|
||
local sounds_list = minetest.get_dir_list(xcompat.modpath.."/src/sounds", false) | ||
local sounds = {} | ||
for _, sound in ipairs(sounds_list) do | ||
local gameid = sound:sub(1, -5) | ||
sounds[gameid] = dofile(xcompat.modpath.."/src/sounds/"..sound) | ||
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 | ||
}) | ||
|
||
minetest.register_chatcommand("xcompat_test_sounds", { | ||
description = "Test sounds", | ||
privs = {server=true}, | ||
func = function(name, _) | ||
local reference_sounds = sounds["xcompat_agnostic"] | ||
|
||
for gameid, game_sounds in pairs(sounds) do | ||
for sound, _ in pairs(reference_sounds) do | ||
if not game_sounds[sound] then | ||
minetest.chat_send_player(name, "Missing material: "..sound.." in game: "..gameid) | ||
end | ||
end | ||
end | ||
|
||
minetest.chat_send_player(name, "Sounds 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,19 @@ | ||
local functions = {} | ||
|
||
function functions.can_interact_with_node(player, pos) | ||
--if we have default, use it | ||
if default then return default.can_interact_with_node(player, pos) end | ||
|
||
local owner = minetest.get_meta(pos):get_string("owner") or "" | ||
|
||
--check that we have a valid player | ||
if not player or not player:is_player() then return false end | ||
--check there privs for compat with areas | ||
if minetest.check_player_privs(player, "protection_bypass") then return true end | ||
--if a normal player, check if they are the owner | ||
if owner == "" or owner == player:get_player_name() then return true end | ||
|
||
return false | ||
end | ||
|
||
return functions |
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,33 @@ | ||
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 | ||
|
||
--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 |
Oops, something went wrong.