diff --git a/.luacheckrc b/.luacheckrc index 3b47b2d..8b3f81d 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -5,6 +5,7 @@ max_line_length = 999 globals = { "minetest", "unified_inventory", "core", "player_api", "clothing", "armor", "sfinv", + "mcl_skins", } read_globals = { diff --git a/api.lua b/api.lua index c408810..ba2a3fb 100644 --- a/api.lua +++ b/api.lua @@ -21,6 +21,19 @@ function skins.get_player_skin(player) storage:set_string(player_name, "") end end + + -- Voxelibre compatibility + if minetest.global_exists("mcl_skins") then + local texture = mcl_skins.player_skins[player].simple_skins_id + if texture then + for k, listed_skin in pairs(skins.meta) do + if listed_skin._texture == texture then + return listed_skin + end + end + end + end + return skin or skins.get(skins.default) end @@ -46,6 +59,13 @@ function skins.assign_player_skin(player, skin) else return false end + + -- Voxelibre compatibility + if minetest.global_exists("mcl_skins") then + mcl_skins.player_skins[player].simple_skins_id = skin_obj:get_texture() + mcl_skins.save(player) + end + return true, skin_obj end @@ -60,6 +80,10 @@ function skins.update_player_skin(player) if minetest.global_exists("sfinv") and sfinv.enabled then sfinv.set_player_inventory_formspec(player) end + -- Voxelibre compatibility + if minetest.global_exists("mcl_skins") then + mcl_skins.update_player_skin(player); + end end end diff --git a/init.lua b/init.lua index 836f2bc..8f0e2e5 100644 --- a/init.lua +++ b/init.lua @@ -29,6 +29,8 @@ dofile(skins.modpath.."/skins_updater.lua") skins.ie = nil skins.http = nil +assert(minetest.global_exists("player_api") or minetest.global_exists("mcl_skins"), "One of player_api or mcl_skins is required.") + -- 3d_armor compatibility if minetest.global_exists("armor") then skins.armor_loaded = true @@ -72,27 +74,29 @@ minetest.register_on_shutdown(function() end end) -player_api.register_model("skinsdb_3d_armor_character_5.b3d", { - animation_speed = 30, - textures = { - "blank.png", - "blank.png", - "blank.png", - "blank.png" - }, - animations = { - stand = {x=0, y=79}, - lay = {x=162, y=166}, - walk = {x=168, y=187}, - mine = {x=189, y=198}, - walk_mine = {x=200, y=219}, - sit = {x=81, y=160}, - -- compatibility w/ the emote mod - wave = {x = 192, y = 196, override_local = true}, - point = {x = 196, y = 196, override_local = true}, - freeze = {x = 205, y = 205, override_local = true}, - }, -}) +if minetest.global_exists("player_api") then + player_api.register_model("skinsdb_3d_armor_character_5.b3d", { + animation_speed = 30, + textures = { + "blank.png", + "blank.png", + "blank.png", + "blank.png" + }, + animations = { + stand = {x=0, y=79}, + lay = {x=162, y=166}, + walk = {x=168, y=187}, + mine = {x=189, y=198}, + walk_mine = {x=200, y=219}, + sit = {x=81, y=160}, + -- compatibility w/ the emote mod + wave = {x = 192, y = 196, override_local = true}, + point = {x = 196, y = 196, override_local = true}, + freeze = {x = 205, y = 205, override_local = true}, + }, + }) +end -- Register default character.png if not part of this mod local default_skin_obj = skins.get(skins.default) diff --git a/mod.conf b/mod.conf index 38a62c3..5d07309 100644 --- a/mod.conf +++ b/mod.conf @@ -1,5 +1,4 @@ name = skinsdb description = Player skin mod, supporting unified_inventory, sfinv and smart_inventory -depends = player_api -optional_depends = unified_inventory,3d_armor,clothing,sfinv,hand_monoid +optional_depends = unified_inventory,3d_armor,clothing,mcl_skins,player_api,sfinv,hand_monoid min_minetest_version = 5.4.0 diff --git a/skin_meta_api.lua b/skin_meta_api.lua index 1ce04ed..10a4f65 100644 --- a/skin_meta_api.lua +++ b/skin_meta_api.lua @@ -159,7 +159,9 @@ function skin_class:apply_skin_to_player(player) local playername = player:get_player_name() local ver = self:get_meta("format") or "1.0" - player_api.set_model(player, "skinsdb_3d_armor_character_5.b3d") + if minetest.global_exists("player_api") then + player_api.set_model(player, "skinsdb_3d_armor_character_5.b3d") + end local v10_texture = "blank.png" local v18_texture = "blank.png" @@ -195,12 +197,14 @@ function skin_class:apply_skin_to_player(player) end end - player_api.set_textures(player, { - v10_texture, - v18_texture, - armor_texture, - wielditem_texture, - }) + if minetest.global_exists("player_api") then + player_api.set_textures(player, { + v10_texture, + v18_texture, + armor_texture, + wielditem_texture, + }) + end player:set_properties({ visual_size = { diff --git a/skinlist.lua b/skinlist.lua index a2d4a27..fb29aed 100644 --- a/skinlist.lua +++ b/skinlist.lua @@ -67,6 +67,10 @@ function skins.register_skin(path, filename) skin_obj._legacy_name = filename_noext:gsub("[._]+", "_") end + if minetest.global_exists("mcl_skins") then + mcl_skins.register_simple_skin({texture = filename}) + end + if playername then skin_obj:set_meta("assignment", "player:"..playername) skin_obj:set_meta("playername", playername)