mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2024-12-23 07:50:18 +01:00
Compatibility with Voxelibre
This allows skinsdb to replace or supplement Voxelibre’s skin system, using its mcl_skins. Downgrades player_api to an optional dependency.
This commit is contained in:
parent
b7cd514cea
commit
c3fdc07781
@ -5,6 +5,7 @@ max_line_length = 999
|
|||||||
globals = {
|
globals = {
|
||||||
"minetest", "unified_inventory", "core",
|
"minetest", "unified_inventory", "core",
|
||||||
"player_api", "clothing", "armor", "sfinv",
|
"player_api", "clothing", "armor", "sfinv",
|
||||||
|
"mcl_skins",
|
||||||
}
|
}
|
||||||
|
|
||||||
read_globals = {
|
read_globals = {
|
||||||
|
21
api.lua
21
api.lua
@ -21,6 +21,18 @@ function skins.get_player_skin(player)
|
|||||||
storage:set_string(player_name, "")
|
storage:set_string(player_name, "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if skins.use_voxelibre_compat 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)
|
return skin or skins.get(skins.default)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -46,6 +58,12 @@ function skins.assign_player_skin(player, skin)
|
|||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if skins.use_voxelibre_compat then
|
||||||
|
mcl_skins.player_skins[player].simple_skins_id = skin_obj:get_texture()
|
||||||
|
mcl_skins.save(player)
|
||||||
|
end
|
||||||
|
|
||||||
return true, skin_obj
|
return true, skin_obj
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -60,6 +78,9 @@ function skins.update_player_skin(player)
|
|||||||
if minetest.global_exists("sfinv") and sfinv.enabled then
|
if minetest.global_exists("sfinv") and sfinv.enabled then
|
||||||
sfinv.set_player_inventory_formspec(player)
|
sfinv.set_player_inventory_formspec(player)
|
||||||
end
|
end
|
||||||
|
if skins.use_voxelibre_compat then
|
||||||
|
mcl_skins.update_player_skin(player);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
9
init.lua
9
init.lua
@ -8,6 +8,9 @@ skins = {}
|
|||||||
skins.modpath = minetest.get_modpath(minetest.get_current_modname())
|
skins.modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
skins.default = "character"
|
skins.default = "character"
|
||||||
|
|
||||||
|
skins.use_voxelibre_compat = minetest.global_exists("mcl_skins")
|
||||||
|
assert(minetest.global_exists("player_api") or minetest.global_exists("mcl_skins"), "One of player_api or mcl_skins is required.")
|
||||||
|
|
||||||
dofile(skins.modpath.."/skin_meta_api.lua")
|
dofile(skins.modpath.."/skin_meta_api.lua")
|
||||||
dofile(skins.modpath.."/api.lua")
|
dofile(skins.modpath.."/api.lua")
|
||||||
dofile(skins.modpath.."/skinlist.lua")
|
dofile(skins.modpath.."/skinlist.lua")
|
||||||
@ -72,7 +75,8 @@ minetest.register_on_shutdown(function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
player_api.register_model("skinsdb_3d_armor_character_5.b3d", {
|
if minetest.global_exists("player_api") then
|
||||||
|
player_api.register_model("skinsdb_3d_armor_character_5.b3d", {
|
||||||
animation_speed = 30,
|
animation_speed = 30,
|
||||||
textures = {
|
textures = {
|
||||||
"blank.png",
|
"blank.png",
|
||||||
@ -92,7 +96,8 @@ player_api.register_model("skinsdb_3d_armor_character_5.b3d", {
|
|||||||
point = {x = 196, y = 196, override_local = true},
|
point = {x = 196, y = 196, override_local = true},
|
||||||
freeze = {x = 205, y = 205, override_local = true},
|
freeze = {x = 205, y = 205, override_local = true},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
-- Register default character.png if not part of this mod
|
-- Register default character.png if not part of this mod
|
||||||
local default_skin_obj = skins.get(skins.default)
|
local default_skin_obj = skins.get(skins.default)
|
||||||
|
3
mod.conf
3
mod.conf
@ -1,5 +1,4 @@
|
|||||||
name = skinsdb
|
name = skinsdb
|
||||||
description = Player skin mod, supporting unified_inventory, sfinv and smart_inventory
|
description = Player skin mod, supporting unified_inventory, sfinv and smart_inventory
|
||||||
depends = player_api
|
optional_depends = unified_inventory,3d_armor,clothing,mcl_skins,player_api,sfinv,hand_monoid
|
||||||
optional_depends = unified_inventory,3d_armor,clothing,sfinv,hand_monoid
|
|
||||||
min_minetest_version = 5.4.0
|
min_minetest_version = 5.4.0
|
||||||
|
@ -159,7 +159,9 @@ function skin_class:apply_skin_to_player(player)
|
|||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
local ver = self:get_meta("format") or "1.0"
|
local ver = self:get_meta("format") or "1.0"
|
||||||
|
|
||||||
|
if minetest.global_exists("player_api") then
|
||||||
player_api.set_model(player, "skinsdb_3d_armor_character_5.b3d")
|
player_api.set_model(player, "skinsdb_3d_armor_character_5.b3d")
|
||||||
|
end
|
||||||
|
|
||||||
local v10_texture = "blank.png"
|
local v10_texture = "blank.png"
|
||||||
local v18_texture = "blank.png"
|
local v18_texture = "blank.png"
|
||||||
@ -195,12 +197,14 @@ function skin_class:apply_skin_to_player(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if minetest.global_exists("player_api") then
|
||||||
player_api.set_textures(player, {
|
player_api.set_textures(player, {
|
||||||
v10_texture,
|
v10_texture,
|
||||||
v18_texture,
|
v18_texture,
|
||||||
armor_texture,
|
armor_texture,
|
||||||
wielditem_texture,
|
wielditem_texture,
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
player:set_properties({
|
player:set_properties({
|
||||||
visual_size = {
|
visual_size = {
|
||||||
|
@ -67,6 +67,10 @@ function skins.register_skin(path, filename)
|
|||||||
skin_obj._legacy_name = filename_noext:gsub("[._]+", "_")
|
skin_obj._legacy_name = filename_noext:gsub("[._]+", "_")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if skins.use_voxelibre_compat then
|
||||||
|
mcl_skins.register_simple_skin({texture = filename})
|
||||||
|
end
|
||||||
|
|
||||||
if playername then
|
if playername then
|
||||||
skin_obj:set_meta("assignment", "player:"..playername)
|
skin_obj:set_meta("assignment", "player:"..playername)
|
||||||
skin_obj:set_meta("playername", playername)
|
skin_obj:set_meta("playername", playername)
|
||||||
|
Loading…
Reference in New Issue
Block a user