mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2025-07-21 16:50:23 +02:00
Compare commits
6 Commits
b769824d24
...
d3c7fa71c0
Author | SHA1 | Date | |
---|---|---|---|
d3c7fa71c0 | |||
1d1053dbc2 | |||
b49907c4b1 | |||
6db9a55f0c | |||
c0b6f761dc | |||
e275159dd0 |
@ -10,4 +10,5 @@ globals = {
|
|||||||
read_globals = {
|
read_globals = {
|
||||||
string = {fields = {"split", "trim"}},
|
string = {fields = {"split", "trim"}},
|
||||||
table = {fields = {"copy", "getn"}},
|
table = {fields = {"copy", "getn"}},
|
||||||
|
"hand_monoid",
|
||||||
}
|
}
|
||||||
|
3
API.md
3
API.md
@ -59,7 +59,8 @@ Could be redefined for dynamic texture generation
|
|||||||
Set the hand node to be used with this skin
|
Set the hand node to be used with this skin
|
||||||
|
|
||||||
## skin:set_hand_from_texture()
|
## skin:set_hand_from_texture()
|
||||||
Register and set hand node based on skin texture
|
Register and set hand node based on skin texture.
|
||||||
|
Uses different model depending on get_meta("format") ("1.0" or "1.8")
|
||||||
Only works on mod load
|
Only works on mod load
|
||||||
|
|
||||||
## skin:get_hand()
|
## skin:get_hand()
|
||||||
|
17
init.lua
17
init.lua
@ -8,6 +8,12 @@ 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"
|
||||||
|
|
||||||
|
-- see skindsdb/textures/readme.txt to avoid playername with underscore problem
|
||||||
|
skins.fsep = minetest.settings:get("skinsdb_fsep") or "_"
|
||||||
|
if skins.fsep == "_" then
|
||||||
|
minetest.log("warning", "skinsdb filename seperator is set to " .. skins.fsep .. ", see skindsdb/textures/readme.txt to avoid problems with playernames containing underscore")
|
||||||
|
end
|
||||||
|
|
||||||
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")
|
||||||
@ -63,6 +69,13 @@ end)
|
|||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
skins.ui_context[player:get_player_name()] = nil
|
skins.ui_context[player:get_player_name()] = nil
|
||||||
|
player:get_inventory():set_size("hand", 0)
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_shutdown(function()
|
||||||
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
|
player:get_inventory():set_size("hand", 0)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
player_api.register_model("skinsdb_3d_armor_character_5.b3d", {
|
player_api.register_model("skinsdb_3d_armor_character_5.b3d", {
|
||||||
@ -80,6 +93,10 @@ player_api.register_model("skinsdb_3d_armor_character_5.b3d", {
|
|||||||
mine = {x=189, y=198},
|
mine = {x=189, y=198},
|
||||||
walk_mine = {x=200, y=219},
|
walk_mine = {x=200, y=219},
|
||||||
sit = {x=81, y=160},
|
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},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
20
locale/skinsdb.pt_BR.tr
Normal file
20
locale/skinsdb.pt_BR.tr
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# textdomain: skinsdb
|
||||||
|
|
||||||
|
Raw texture=Textura crua
|
||||||
|
Name=Nome
|
||||||
|
Author=Autor
|
||||||
|
Change=Mudar
|
||||||
|
Page=Página
|
||||||
|
License=Licença
|
||||||
|
Description=Descrição
|
||||||
|
Show, list or set player's skin=Mostrar, listar ou definir a skin do jogador
|
||||||
|
Player not found=Jogador não encontrado
|
||||||
|
unknown command=Comando desconhecido
|
||||||
|
see /help skinsdb for supported parameters= consulte /help skinsdb para obter os parâmetros suportados
|
||||||
|
skin set to=Aparência definida para
|
||||||
|
invalid skin=Aparência inválida
|
||||||
|
unknown parameter=parâmetro desconhecido
|
||||||
|
unknown skin=Aparência desconhecida
|
||||||
|
Downloads thespecified range of skins and shuts down the server= Baixa o intervalo especificado de capas e desliga o servidor
|
||||||
|
Skins=Aparência
|
||||||
|
Requires skin key=Requer chave de aparência
|
2
mod.conf
2
mod.conf
@ -1,5 +1,5 @@
|
|||||||
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
|
depends = player_api
|
||||||
optional_depends = unified_inventory,3d_armor,clothing,sfinv
|
optional_depends = unified_inventory,3d_armor,clothing,sfinv,hand_monoid
|
||||||
min_minetest_version = 5.4.0
|
min_minetest_version = 5.4.0
|
||||||
|
BIN
models/skinsdb_hand_18.b3d
Normal file
BIN
models/skinsdb_hand_18.b3d
Normal file
Binary file not shown.
BIN
models/skinsdb_hand_18.blend
Normal file
BIN
models/skinsdb_hand_18.blend
Normal file
Binary file not shown.
3
settingtypes.txt
Normal file
3
settingtypes.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# texture filename seperator, default "_"
|
||||||
|
# see skindsdb/textures/readme.txt to avoid playername with underscore problem
|
||||||
|
skinsdb_fsep (texture filename seperator) enum _ _,.
|
@ -1,5 +1,7 @@
|
|||||||
skins.meta = {}
|
skins.meta = {}
|
||||||
|
|
||||||
|
local has_hand_monoid = minetest.get_modpath("hand_monoid")
|
||||||
|
|
||||||
local skin_class = {}
|
local skin_class = {}
|
||||||
skin_class.__index = skin_class
|
skin_class.__index = skin_class
|
||||||
skins.skin_class = skin_class
|
skins.skin_class = skin_class
|
||||||
@ -69,7 +71,11 @@ function skin_class:set_hand_from_texture()
|
|||||||
hand_def.wield_scale = {x=1,y=1,z=1}
|
hand_def.wield_scale = {x=1,y=1,z=1}
|
||||||
hand_def.paramtype = "light"
|
hand_def.paramtype = "light"
|
||||||
hand_def.drawtype = "mesh"
|
hand_def.drawtype = "mesh"
|
||||||
|
if(self:get_meta("format") == "1.0") then
|
||||||
hand_def.mesh = "skinsdb_hand.b3d"
|
hand_def.mesh = "skinsdb_hand.b3d"
|
||||||
|
else
|
||||||
|
hand_def.mesh = "skinsdb_hand_18.b3d"
|
||||||
|
end
|
||||||
hand_def.use_texture_alpha = ALPHA_CLIP
|
hand_def.use_texture_alpha = ALPHA_CLIP
|
||||||
minetest.register_node(hand, hand_def)
|
minetest.register_node(hand, hand_def)
|
||||||
self:set_hand(hand)
|
self:set_hand(hand)
|
||||||
@ -204,12 +210,20 @@ function skin_class:apply_skin_to_player(player)
|
|||||||
})
|
})
|
||||||
|
|
||||||
local hand = self:get_hand()
|
local hand = self:get_hand()
|
||||||
|
if has_hand_monoid then
|
||||||
|
if hand then
|
||||||
|
hand_monoid.monoid:add_change(player, {name = hand}, "skinsdb:hand")
|
||||||
|
else
|
||||||
|
hand_monoid.monoid:del_change(player, "skinsdb:hand")
|
||||||
|
end
|
||||||
|
else
|
||||||
if hand then
|
if hand then
|
||||||
player:get_inventory():set_size("hand", 1)
|
player:get_inventory():set_size("hand", 1)
|
||||||
player:get_inventory():set_stack("hand", 1, hand)
|
player:get_inventory():set_stack("hand", 1, hand)
|
||||||
else
|
else
|
||||||
player:get_inventory():set_stack("hand", 1, "")
|
player:get_inventory():set_stack("hand", 1, "")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function skin_class:set_skin(player)
|
function skin_class:set_skin(player)
|
||||||
|
@ -2,7 +2,7 @@ local skins_dir_list = minetest.get_dir_list(skins.modpath.."/textures")
|
|||||||
|
|
||||||
for _, fn in pairs(skins_dir_list) do
|
for _, fn in pairs(skins_dir_list) do
|
||||||
local name, sort_id, is_preview, playername
|
local name, sort_id, is_preview, playername
|
||||||
local nameparts = string.gsub(fn, "[.]", "_"):split("_")
|
local nameparts = string.gsub(fn, "[.]", skins.fsep):split(skins.fsep)
|
||||||
|
|
||||||
-- check allowed prefix and file extension
|
-- check allowed prefix and file extension
|
||||||
if (nameparts[1] == 'player' or nameparts[1] == 'character') and
|
if (nameparts[1] == 'player' or nameparts[1] == 'character') and
|
||||||
@ -51,9 +51,7 @@ for _, fn in pairs(skins_dir_list) do
|
|||||||
local skin_format = skins.get_skin_format(file)
|
local skin_format = skins.get_skin_format(file)
|
||||||
skin_obj:set_meta("format", skin_format)
|
skin_obj:set_meta("format", skin_format)
|
||||||
file:close()
|
file:close()
|
||||||
if skin_format == "1.0" then
|
|
||||||
skin_obj:set_hand_from_texture()
|
skin_obj:set_hand_from_texture()
|
||||||
end
|
|
||||||
file = io.open(skins.modpath.."/meta/"..name..".txt", "r")
|
file = io.open(skins.modpath.."/meta/"..name..".txt", "r")
|
||||||
if file then
|
if file then
|
||||||
local data = string.split(file:read("*all"), "\n", 3)
|
local data = string.split(file:read("*all"), "\n", 3)
|
||||||
|
@ -88,7 +88,7 @@ local function safe_single_skin(skin)
|
|||||||
skin.license
|
skin.license
|
||||||
}
|
}
|
||||||
|
|
||||||
local name = "character_" .. skin.id
|
local name = "character" .. skins.fsep .. skin.id
|
||||||
|
|
||||||
-- core.safe_file_write does not work here
|
-- core.safe_file_write does not work here
|
||||||
unsafe_file_write(
|
unsafe_file_write(
|
||||||
@ -101,7 +101,7 @@ local function safe_single_skin(skin)
|
|||||||
core.decode_base64(skin.img)
|
core.decode_base64(skin.img)
|
||||||
)
|
)
|
||||||
fetch_url(preview_url:format(skin.id), function(preview)
|
fetch_url(preview_url:format(skin.id), function(preview)
|
||||||
unsafe_file_write(skins_path .. name .. "_preview.png", preview)
|
unsafe_file_write(skins_path .. name .. skins.fsep .. "preview.png", preview)
|
||||||
end)
|
end)
|
||||||
core.log("action", ("%s: Completed skin %s"):format(_ID_, name))
|
core.log("action", ("%s: Completed skin %s"):format(_ID_, name))
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
In this folder the skin files could be placed according the following file naming convention.
|
In this folder the skin files could be placed according the following file naming convention.
|
||||||
|
|
||||||
|
skinsdb uses an underscore as default seperator for filename splitting which can cause problems with playernames containing "_",
|
||||||
|
see https://github.com/minetest-mods/skinsdb/issues/54.
|
||||||
|
The config setting skinsdb_fsep (texture filename seperator) was added as a workaround which also offers "."(dot) as seperator,
|
||||||
|
dot is the only character which is allowed in textures but not in playernames.
|
||||||
|
To keep compatibility with older versions underscore is the default value.
|
||||||
|
|
||||||
|
fresh install:
|
||||||
|
you should change the seperator to "." to avoid that problem.
|
||||||
|
existing install:
|
||||||
|
- change the filenames according to the naming convention with dot as seperator instead of underscore
|
||||||
|
- change the texture filename seperator in settings or add "skinsdb_fsep = ." to your minetest.conf before starting your server
|
||||||
|
|
||||||
Public skin available for all users:
|
Public skin available for all users:
|
||||||
character_[number-or-name].png
|
character_[number-or-name].png
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
import sys, requests, base64
|
import sys, requests, base64
|
||||||
|
|
||||||
|
# filename seperator to use, either default "-" or ".". see skinsdb/textures/readme.txt
|
||||||
|
#fsep = "_"
|
||||||
|
fsep = "."
|
||||||
|
|
||||||
download_preview = ( len (sys.argv) > 1 and sys.argv[1] == "with_preview" )
|
download_preview = ( len (sys.argv) > 1 and sys.argv[1] == "with_preview" )
|
||||||
|
|
||||||
|
|
||||||
@ -24,7 +28,7 @@ for json in data["skins"]:
|
|||||||
|
|
||||||
# Texture file
|
# Texture file
|
||||||
raw_data = base64.b64decode(json["img"])
|
raw_data = base64.b64decode(json["img"])
|
||||||
file = open("../textures/character_" + id + ".png", "wb")
|
file = open("../textures/character" + fsep + id + ".png", "wb")
|
||||||
file.write(bytearray(raw_data))
|
file.write(bytearray(raw_data))
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
@ -44,7 +48,7 @@ for json in data["skins"]:
|
|||||||
if r2.status_code == 200:
|
if r2.status_code == 200:
|
||||||
# Preview file
|
# Preview file
|
||||||
preview = r2.content
|
preview = r2.content
|
||||||
file = open("../textures/character_" + id + "_preview.png", "wb")
|
file = open("../textures/character_" + id + fsep + "preview.png", "wb")
|
||||||
file.write(bytearray(preview))
|
file.write(bytearray(preview))
|
||||||
file.close()
|
file.close()
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user