mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2025-07-22 17:20:22 +02:00
Compare commits
4 Commits
da820d06cb
...
03d424fea7
Author | SHA1 | Date | |
---|---|---|---|
03d424fea7 | |||
c9fa5d92df | |||
af5e6fcecc | |||
2e39651821 |
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)
|
||||
|
@ -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
|
||||
|
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)
|
||||
|
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)
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user