mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2025-09-08 14:45:35 +02:00
Compare commits
10 Commits
716a9a3f9a
...
b769824d24
Author | SHA1 | Date | |
---|---|---|---|
|
b769824d24 | ||
|
03d424fea7 | ||
|
c9fa5d92df | ||
|
af5e6fcecc | ||
|
2e39651821 | ||
|
da820d06cb | ||
|
cf712e5b54 | ||
|
c51905d44b | ||
|
b3ea5a9e1f | ||
|
e479e8e745 |
11
.github/workflows/build.yml
vendored
Normal file
11
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
on: [push, pull_request]
|
||||
name: build
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: lint
|
||||
uses: Roang-zero1/factorio-mod-luacheck@master
|
||||
with:
|
||||
luacheckrc_url: ""
|
13
.luacheckrc
Normal file
13
.luacheckrc
Normal file
@@ -0,0 +1,13 @@
|
||||
unused_args = false
|
||||
allow_defined_top = true
|
||||
max_line_length = 999
|
||||
|
||||
globals = {
|
||||
"minetest", "unified_inventory", "core",
|
||||
"player_api", "clothing", "armor", "sfinv",
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
string = {fields = {"split", "trim"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
}
|
12
API.md
12
API.md
@@ -55,6 +55,16 @@ Get the skin texture for any reason. Note to apply them the skin:set_skin() shou
|
||||
|
||||
Could be redefined for dynamic texture generation
|
||||
|
||||
## skin:set_hand(hand_node)
|
||||
Set the hand node to be used with this skin
|
||||
|
||||
## skin:set_hand_from_texture()
|
||||
Register and set hand node based on skin texture
|
||||
Only works on mod load
|
||||
|
||||
## skin:get_hand()
|
||||
Get hand node. Returns ItemStack
|
||||
|
||||
## skin:set_preview(texture)
|
||||
Set the skin preview - usually at the init time only
|
||||
|
||||
@@ -67,7 +77,7 @@ Could be redefined for dynamic preview texture generation
|
||||
Hook for dynamic skins updates on select. Is called in skins.set_player_skin()
|
||||
In skinsdb the default implementation for this function is empty.
|
||||
|
||||
skin:apply_skin_to_player(player)
|
||||
## skin:apply_skin_to_player(player)
|
||||
Apply the skin to the player. Called in skins.update_player_skin() to update visuals
|
||||
|
||||
## skin:set_meta(key, value)
|
||||
|
@@ -15,6 +15,7 @@ This Minetest mod offers changeable player skins with a graphical interface for
|
||||
- Support for different skins lists: public and a per-player list are currently implemented
|
||||
- Full [3d_armor](https://forum.minetest.net/viewtopic.php?t=4654) support
|
||||
- Compatible to 1.0 and 1.8 Minecraft skins format
|
||||
- Skinned hand in 1st person view (1.0 skins only)
|
||||
|
||||
|
||||
## Installing skins
|
||||
@@ -53,6 +54,7 @@ The Script will download all the skins from the database for you.
|
||||
## License:
|
||||
- GPLv3
|
||||
- skin texture licenses: See "meta" folder
|
||||
- hand model: CC0
|
||||
|
||||
### Credits
|
||||
|
||||
@@ -62,3 +64,4 @@ The Script will download all the skins from the database for you.
|
||||
- Krock (source code)
|
||||
- bell07 (source code)
|
||||
- stujones11 (player models)
|
||||
- jordan4ibanez (1st person view hand)
|
||||
|
5
api.lua
5
api.lua
@@ -34,7 +34,7 @@ function skins.assign_player_skin(player, skin)
|
||||
else
|
||||
return false
|
||||
end
|
||||
return true
|
||||
return true, skin_obj
|
||||
end
|
||||
|
||||
-- update visuals
|
||||
@@ -53,10 +53,11 @@ end
|
||||
|
||||
-- Assign and update - should be used on selection externally
|
||||
function skins.set_player_skin(player, skin)
|
||||
local success = skins.assign_player_skin(player, skin)
|
||||
local success, skin_obj = skins.assign_player_skin(player, skin)
|
||||
if success then
|
||||
skins.get_player_skin(player):set_skin(player)
|
||||
skins.update_player_skin(player)
|
||||
minetest.log("action", player:get_player_name().." set skin to "..skin_obj:get_key(""))
|
||||
end
|
||||
return success
|
||||
end
|
||||
|
@@ -1,5 +1,5 @@
|
||||
local S = minetest.get_translator("skinsdb")
|
||||
local ui = unified_inventory
|
||||
local ui = minetest.global_exists("unified_inventory") and unified_inventory
|
||||
|
||||
function skins.get_formspec_context(player)
|
||||
if player then
|
||||
@@ -57,7 +57,7 @@ function skins.get_skin_selection_formspec(player, context, perplayer_formspec)
|
||||
local yspc = 2
|
||||
local skinwidth = 1
|
||||
local skinheight = 2
|
||||
local xscale = 1
|
||||
local xscale = 1 -- luacheck: ignore
|
||||
local btn_y = 8.15
|
||||
local drop_y = 8
|
||||
local btn_width = 1
|
||||
@@ -104,7 +104,7 @@ function skins.get_skin_selection_formspec(player, context, perplayer_formspec)
|
||||
|
||||
local page = context.skins_page
|
||||
local formspec = ""
|
||||
|
||||
|
||||
for i = (page-1)*maxdisp+1, page*maxdisp do
|
||||
local skin = context.skins_list[i]
|
||||
if not skin then
|
||||
|
8
init.lua
8
init.lua
@@ -91,4 +91,12 @@ if not default_skin_obj then
|
||||
default_skin_obj:set_meta("format", '1.0')
|
||||
default_skin_obj:set_meta("_sort_id", 0)
|
||||
default_skin_obj:set_meta("name", "Sam")
|
||||
default_skin_obj:set_hand_from_texture()
|
||||
end
|
||||
|
||||
-- Secure hand inventory slot
|
||||
minetest.register_allow_player_inventory_action(function(player, action, inv, data)
|
||||
if data.to_list == "hand" or data.from_list == "hand" or data.listname == "hand" then
|
||||
return 0
|
||||
end
|
||||
end)
|
||||
|
21
locale/skinsdb.ru.tr
Normal file
21
locale/skinsdb.ru.tr
Normal file
@@ -0,0 +1,21 @@
|
||||
# textdomain: skinsdb
|
||||
# Translation by Baytuch
|
||||
|
||||
Raw texture=Текстура
|
||||
Name=Имя
|
||||
Author=Автор
|
||||
Change=Изменить
|
||||
Page=Страница
|
||||
License=Лицензия
|
||||
Description=Описание
|
||||
Show, list or set player's skin=Показать скин, список скинов, установить скин игрока
|
||||
Player not found=Игрок не найден
|
||||
unknown command=неизвестная команда
|
||||
see /help skinsdb for supported parameters=смотрите /help skinsdb для просмотра параметров
|
||||
skin set to=установлено скин
|
||||
invalid skin=некорректный скин
|
||||
unknown parameter=неопределенный параметр
|
||||
unknown skin=неопределенный скин
|
||||
Downloads the specified range of skins and shuts down the server=Загрузить массив скинов и остановить сервер
|
||||
Skins=Скины
|
||||
Requires skin key=Зависимый идентификатор скина
|
21
locale/skinsdb.uk.tr
Normal file
21
locale/skinsdb.uk.tr
Normal file
@@ -0,0 +1,21 @@
|
||||
# textdomain: skinsdb
|
||||
# Translation by Baytuch
|
||||
|
||||
Raw texture=Текстура
|
||||
Name=Ім'я
|
||||
Author=Автор
|
||||
Change=Змінити
|
||||
Page=Сторінка
|
||||
License=Ліцензія
|
||||
Description=Опис
|
||||
Show, list or set player's skin=Показати скін, список скінів, встановити скін гравця
|
||||
Player not found=Гравець не знайдений
|
||||
unknown command=невідома команда
|
||||
see /help skinsdb for supported parameters=дивіться /help skinsdb для перегляду параметрів
|
||||
skin set to=встановлено скін
|
||||
invalid skin=некоректний скін
|
||||
unknown parameter=невизначений параметр
|
||||
unknown skin=невизначений скін
|
||||
Downloads the specified range of skins and shuts down the server=Завантажити масив скінів та зупинити сервер
|
||||
Skins=Скіни
|
||||
Requires skin key=Залежний ідентифікатор скіна
|
BIN
models/skinsdb_hand.b3d
Normal file
BIN
models/skinsdb_hand.b3d
Normal file
Binary file not shown.
BIN
models/skinsdb_hand.blend
Normal file
BIN
models/skinsdb_hand.blend
Normal file
Binary file not shown.
@@ -51,6 +51,34 @@ function skin_class:get_texture()
|
||||
return self._texture
|
||||
end
|
||||
|
||||
function skin_class:set_hand(hand)
|
||||
self._hand = hand
|
||||
end
|
||||
|
||||
local ALPHA_CLIP = minetest.features.use_texture_alpha_string_modes and "clip" or true
|
||||
function skin_class:set_hand_from_texture()
|
||||
local hand = core.get_current_modname()..':'..self._texture:gsub('[%p%c%s]', '')
|
||||
local hand_def = {}
|
||||
for k,v in pairs(minetest.registered_items[""]) do
|
||||
if k ~= "mod_origin" and k ~= "type" and k ~= "wield_image" then
|
||||
hand_def[k] = v
|
||||
end
|
||||
end
|
||||
hand_def.tiles = {self:get_texture()}
|
||||
hand_def.visual_scale = 1
|
||||
hand_def.wield_scale = {x=1,y=1,z=1}
|
||||
hand_def.paramtype = "light"
|
||||
hand_def.drawtype = "mesh"
|
||||
hand_def.mesh = "skinsdb_hand.b3d"
|
||||
hand_def.use_texture_alpha = ALPHA_CLIP
|
||||
minetest.register_node(hand, hand_def)
|
||||
self:set_hand(hand)
|
||||
end
|
||||
|
||||
function skin_class:get_hand()
|
||||
return self._hand
|
||||
end
|
||||
|
||||
function skin_class:set_preview(value)
|
||||
self._preview = value
|
||||
end
|
||||
@@ -174,6 +202,14 @@ function skin_class:apply_skin_to_player(player)
|
||||
y = self:get_meta("visual_size_y") or 1
|
||||
}
|
||||
})
|
||||
|
||||
local hand = self:get_hand()
|
||||
if hand then
|
||||
player:get_inventory():set_size("hand", 1)
|
||||
player:get_inventory():set_stack("hand", 1, hand)
|
||||
else
|
||||
player:get_inventory():set_stack("hand", 1, "")
|
||||
end
|
||||
end
|
||||
|
||||
function skin_class:set_skin(player)
|
||||
@@ -185,6 +221,6 @@ end
|
||||
function skin_class:is_applicable_for_player(playername)
|
||||
local assigned_player = self:get_meta("playername")
|
||||
return assigned_player == nil or assigned_player == true or
|
||||
playername and (minetest.check_player_privs(playername, {server=true}) or
|
||||
assigned_player:lower() == playername:lower())
|
||||
playername and (minetest.check_player_privs(playername, {server=true}) or
|
||||
assigned_player:lower() == playername:lower())
|
||||
end
|
||||
|
12
skinlist.lua
12
skinlist.lua
@@ -1,7 +1,7 @@
|
||||
local skins_dir_list = minetest.get_dir_list(skins.modpath.."/textures")
|
||||
|
||||
for _, fn in pairs(skins_dir_list) do
|
||||
local name, sort_id, assignment, is_preview, playername
|
||||
local name, sort_id, is_preview, playername
|
||||
local nameparts = string.gsub(fn, "[.]", "_"):split("_")
|
||||
|
||||
-- check allowed prefix and file extension
|
||||
@@ -48,8 +48,12 @@ for _, fn in pairs(skins_dir_list) do
|
||||
skin_obj:set_meta("playername", playername)
|
||||
end
|
||||
local file = io.open(skins.modpath.."/textures/"..fn, "r")
|
||||
skin_obj:set_meta("format", skins.get_skin_format(file))
|
||||
local skin_format = skins.get_skin_format(file)
|
||||
skin_obj:set_meta("format", skin_format)
|
||||
file:close()
|
||||
if skin_format == "1.0" then
|
||||
skin_obj:set_hand_from_texture()
|
||||
end
|
||||
file = io.open(skins.modpath.."/meta/"..name..".txt", "r")
|
||||
if file then
|
||||
local data = string.split(file:read("*all"), "\n", 3)
|
||||
@@ -73,9 +77,9 @@ local function skins_sort(skinslist)
|
||||
local a_id = a:get_meta("_sort_id") or 10000
|
||||
local b_id = b:get_meta("_sort_id") or 10000
|
||||
if a_id ~= b_id then
|
||||
return a:get_meta("_sort_id") < b:get_meta("_sort_id")
|
||||
return a_id < b_id
|
||||
else
|
||||
return a:get_meta("name") < b:get_meta("name")
|
||||
return (a:get_meta("name") or 'ZZ') < (b:get_meta("name") or 'ZZ')
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@@ -115,7 +115,7 @@ internal.get_pages_count = function(callback, ...)
|
||||
callback(math.ceil(list.pages / 20), unpack(vars))
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
-- Function to fetch a range of pages
|
||||
internal.fetch_function = function(pages_total, start_page, len)
|
||||
start_page = math.max(start_page, 1)
|
||||
|
Reference in New Issue
Block a user