mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2025-07-20 16:20:23 +02:00
Compare commits
6 Commits
pr_105_del
...
247bcdd058
Author | SHA1 | Date | |
---|---|---|---|
247bcdd058 | |||
a0ed992121 | |||
3cf80c9272 | |||
df62f2042d | |||
b7cd514cea | |||
11bb5bad0e |
25
API.md
25
API.md
@ -27,6 +27,31 @@ Get all allowed skins for player. All public and all player's private skins. If
|
||||
Get all skins with metadata key is set to value. Example:
|
||||
skins.get_skinlist_with_meta("playername", playername) - Get all private skins (w.o. public) for playername
|
||||
|
||||
## skins.register_skin(path, filename)
|
||||
Registers a new skin based on the texture file path specified by `path` and `filename`.
|
||||
|
||||
* `path` (string): points to the parent directory of the texture `filename`.
|
||||
Generally, this should be in the format `mymod.modpath .. "/textures"`.
|
||||
* `filename` (string): full file name, without any path specifications.
|
||||
The file name must adhere to [one of the accepted naming formats](textures/readme.txt).
|
||||
|
||||
Note: this function takes the following files into consideration:
|
||||
|
||||
1. `<path>/<filename>` (required)
|
||||
* Main skin texture
|
||||
2. `<path>/<filenamestem><separator>preview.png` (optional)
|
||||
* Pre-generated preview image
|
||||
3. `<path>/../meta/<filenamestem>.txt` (optional)
|
||||
* Metadata regarding the skin
|
||||
|
||||
Return values:
|
||||
|
||||
* On failure: `false, reason`
|
||||
* `reason` (string): human readable reason string (similar to `io.open` errors)
|
||||
* On success: `true, key`
|
||||
* `key`: unique skins key for use with e.g. `skins.get(key)` for subsequent
|
||||
fine-tuning of the skin registration.
|
||||
|
||||
|
||||
## skins.new(key, object)
|
||||
Create and register a new skin object for given key
|
||||
|
10
init.lua
10
init.lua
@ -72,6 +72,7 @@ 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 = {
|
||||
@ -82,16 +83,21 @@ player_api.register_model("skinsdb_3d_armor_character_5.b3d", {
|
||||
},
|
||||
animations = {
|
||||
stand = {x=0, y=79},
|
||||
lay = {x=162, y=166},
|
||||
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}},
|
||||
walk = {x=168, y=187},
|
||||
mine = {x=189, y=198},
|
||||
walk_mine = {x=200, y=219},
|
||||
sit = {x=81, y=160},
|
||||
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}},
|
||||
-- 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
|
||||
|
@ -109,7 +109,7 @@ function skin_class:get_preview()
|
||||
--Right Leg
|
||||
skin = skin .. "([combine:16x32:0,0=" .. player_skin .. "^[mask:skindb_mask_rleg.png)^"
|
||||
|
||||
-- 64x skins have non-mirrored arms and legs
|
||||
-- 64x64 skins have non-mirrored arms and legs
|
||||
local left_arm
|
||||
local left_leg
|
||||
|
||||
@ -126,17 +126,21 @@ function skin_class:get_preview()
|
||||
--Left Leg
|
||||
skin = skin .. left_leg
|
||||
|
||||
-- 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
|
||||
skin = skin .. "([combine:16x32:-44,-28=" .. player_skin .. "^[mask:skindb_mask_rarm.png)^"
|
||||
--Right Leg Overlay
|
||||
skin = skin .. "([combine:16x32:0,-16=" .. player_skin .. "^[mask:skindb_mask_rleg.png)^"
|
||||
--Left Arm Overlay
|
||||
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))"
|
||||
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.
|
||||
|
||||
--Chest Overlay
|
||||
skin = skin .. "([combine:16x32:-16,-28=" .. player_skin .. "^[mask:skindb_mask_chest.png)^"
|
||||
--Right Arm Overlay
|
||||
skin = skin .. "([combine:16x32:-44,-28=" .. player_skin .. "^[mask:skindb_mask_rarm.png)^"
|
||||
--Right Leg Overlay
|
||||
skin = skin .. "([combine:16x32:0,-16=" .. player_skin .. "^[mask:skindb_mask_rleg.png)^"
|
||||
--Left Arm Overlay
|
||||
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)"
|
||||
|
@ -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,6 +92,7 @@ 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
|
||||
|
||||
@ -102,6 +103,7 @@ 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
|
||||
|
||||
|
@ -6,6 +6,7 @@ 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
|
||||
|
@ -9,12 +9,14 @@ local function run_unittest()
|
||||
|
||||
-- -----
|
||||
-- `.`: Simple register + retrieve operations
|
||||
skins.register_skin(PATH, "player.DotSep.png")
|
||||
skins.register_skin(PATH, "player._DotSep_666_.1.png")
|
||||
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"))
|
||||
|
||||
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
|
||||
@ -42,7 +44,6 @@ 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
|
||||
|
||||
|
Reference in New Issue
Block a user