2 Commits

Author SHA1 Message Date
cae0fe50ae improve 2024-06-25 21:54:59 +02:00
1efe13939e API: make skins.register_skin public 2024-06-25 21:48:41 +02:00
24 changed files with 34 additions and 101 deletions

4
.gitignore vendored
View File

@ -1,4 +1,4 @@
#textures/character_*.png
textures/character_*.png
textures/player_*.png
#meta/character_*.txt
meta/character_*.txt
meta/player_*.txt

View File

@ -1,4 +1,4 @@
# skinsdb - User-facing branch that includes a few basic skins
# skinsdb
This Minetest mod offers changeable player skins with a graphical interface for multiple inventory mods.
@ -66,4 +66,3 @@ The Script will download all the skins from the database for you.
- bell07 (source code)
- stujones11 (player models)
- jordan4ibanez (1st person view hand)
- sirrobzeroone (skins)

View File

@ -72,7 +72,6 @@ minetest.register_on_shutdown(function()
end
end)
-- See also: 3d_armor/init.lua
player_api.register_model("skinsdb_3d_armor_character_5.b3d", {
animation_speed = 30,
textures = {
@ -83,21 +82,16 @@ player_api.register_model("skinsdb_3d_armor_character_5.b3d", {
},
animations = {
stand = {x=0, y=79},
lay = {x=162, y=166, eye_height = 0.3, override_local = true,
collisionbox = {-0.6, 0.0, -0.6, 0.6, 0.3, 0.6}},
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, eye_height = 0.8, override_local = true,
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.0, 0.3}},
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},
},
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
-- stepheight: use default
eye_height = 1.47,
})
-- Register default character.png if not part of this mod

View File

@ -1,3 +0,0 @@
Castaway female
sirrobzeroone
CC0/Public Domain

View File

@ -1,3 +0,0 @@
Castaway male
sirrobzeroone
CC0/Public Domain

View File

@ -1,3 +0,0 @@
Farmer female
sirrobzeroone
CC0/Public Domain

View File

@ -1,3 +0,0 @@
Farmer male
sirrobzeroone
CC0/Public Domain

View File

@ -1,3 +0,0 @@
Prince
sirrobzeroone
CC0/Public Domain

View File

@ -1,3 +0,0 @@
Princess
sirrobzeroone
CC0/Public Domain

View File

@ -1,3 +0,0 @@
Rogue female
sirrobzeroone
CC0/Public Domain

View File

@ -1,3 +0,0 @@
Rogue male
sirrobzeroone
CC0/Public Domain

View File

@ -1,5 +1,5 @@
name = skinsdb
description = Player skin mod, supporting unified_inventory, sfinv and smart_inventory
depends = player_api
optional_depends = unified_inventory, 3d_armor, clothing, creative, sfinv, hand_monoid
optional_depends = unified_inventory,3d_armor,clothing,sfinv,hand_monoid
min_minetest_version = 5.4.0

View File

@ -49,25 +49,23 @@ function skin_class:set_texture(value)
self._texture = value
end
--- Retrieves the character texture
function skin_class:get_texture()
return self._texture
end
--- Assigns an existing hand item (/node) name to this skin
function skin_class:set_hand(hand)
self._hand = hand
end
function skin_class:get_hand()
return self._hand
end
--- Registers a new hand item based on the skin meta
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}
@ -79,39 +77,13 @@ function skin_class:set_hand_from_texture()
hand_def.mesh = "skinsdb_hand_18.b3d"
end
hand_def.use_texture_alpha = ALPHA_CLIP
core.register_node(hand, table.copy(hand_def))
self._hand_def = hand_def -- for wieldhand overrides
minetest.register_node(hand, hand_def)
self:set_hand(hand)
end
-- creative (and other mods?) may overwrite the wieldhand very late.
-- Grab the most recent definition and use them as default for our skin hands.
core.register_on_mods_loaded(function()
local default_hand_def = {}
for k, v in pairs(core.registered_items[""]) do
if k ~= "mod_origin"
and k ~= "name"
and k ~= "type"
and k ~= "wield_image"
and string.sub(k, 1, 1) ~= "_" then
default_hand_def[k] = v
function skin_class:get_hand()
return self._hand
end
end
for _, meta in pairs(skins.meta) do
local def = core.registered_nodes[meta._hand]
if def then
local new_def = table.copy(default_hand_def)
-- Overwrite the hand with our fields from `set_hand_from_texture`
for k, v in pairs(meta._hand_def) do
new_def[k] = v
end
core.override_item(meta._hand, new_def)
end
meta._hand_def = nil -- no longer needed, free up RAM
end
end)
function skin_class:set_preview(value)
self._preview = value
@ -137,7 +109,7 @@ function skin_class:get_preview()
--Right Leg
skin = skin .. "([combine:16x32:0,0=" .. player_skin .. "^[mask:skindb_mask_rleg.png)^"
-- 64x64 skins have non-mirrored arms and legs
-- 64x skins have non-mirrored arms and legs
local left_arm
local left_leg
@ -154,10 +126,7 @@ function skin_class:get_preview()
--Left Leg
skin = skin .. left_leg
if self:get_meta("format") == "1.8" then
-- Add overlays for 64x64 skins. This check is needed to avoid
-- client-side out-of-bounds "[combine" warnings.
-- Add overlays for 64x skins. these wont appear if skin is 32x because it will be cropped out
--Chest Overlay
skin = skin .. "([combine:16x32:-16,-28=" .. player_skin .. "^[mask:skindb_mask_chest.png)^"
--Right Arm Overlay
@ -168,7 +137,6 @@ function skin_class:get_preview()
skin = skin .. "([combine:16x32:-40,-44=" .. player_skin .. "^[mask:(skindb_mask_rarm.png^[transformFX))^"
--Left Leg Overlay
skin = skin .. "([combine:16x32:4,-32=" .. player_skin .. "^[mask:(skindb_mask_rleg.png^[transformFX))"
end
-- Full Preview
skin = "(((" .. skin .. ")^[resize:64x128)^[mask:skindb_transform.png)"

View File

@ -6,7 +6,7 @@ local dbgprint = false and print or function() end
function skins.register_skin(path, filename)
-- See "textures/readme.txt" for allowed formats
local prefix, sep, identifier, extension = filename:match("^(%a+)([_.])([%w_.-]+)%.(%a+)$")
local prefix, sep, identifier, extension = filename:match("^(%a+)([_.])([%w_.]+)%.(%a+)$")
--[[
prefix: "character" or "player"
sep: "." (new) or "_" (legacy)
@ -92,7 +92,6 @@ function skins.register_skin(path, filename)
skin_obj:set_meta("name", data[1])
skin_obj:set_meta("author", data[2])
skin_obj:set_meta("license", data[3])
file:close() -- do not rely on delayed GC
end
end
@ -103,7 +102,6 @@ function skins.register_skin(path, filename)
if fh then
dbgprint("Found preview", preview_name)
skin_obj:set_preview(preview_name)
fh:close() -- do not rely on delayed GC
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -6,7 +6,6 @@ List of accepted texture names
Public skin available for all users:
character.[number or name].png
^ The allowed characters in "[number or name]" are "[A-z0-9_.-]+".
One or multiple private skins for player "[nick]":
player.[nick].png

View File

@ -9,14 +9,12 @@ local function run_unittest()
-- -----
-- `.`: Simple register + retrieve operations
assert(skins.register_skin(PATH, "player.DotSep.png"))
assert(skins.register_skin(PATH, "player._DotSep_666_.1.png"))
assert(skins.register_skin(PATH, "character._DotSep_With-Dash-.png"))
skins.register_skin(PATH, "player.DotSep.png")
skins.register_skin(PATH, "player._DotSep_666_.1.png")
assert(get_skin("player.DotSep"))
assert(get_skin("player._DotSep_666_.1"))
assert(get_skin("player.DotSep.1") == nil)
assert(get_skin("character._DotSep_With-Dash-"))
-- -----
-- Ambiguous skin names (filenames without extension). Register + retrieve
@ -44,6 +42,7 @@ local function run_unittest()
assert(get_skin("player_Com_Pat_42") == "player._Com_Pat_42")
assert(get_skin("player_Com_Pat_42_1") == "player._Com_Pat_42.1")
error("Unittest passed! Please disable them now.")
end