mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2024-12-22 23:40:18 +01:00
implement skinned 1st person view hand
This commit is contained in:
parent
da820d06cb
commit
2e39651821
9
API.md
9
API.md
@ -55,6 +55,15 @@ Get the skin texture for any reason. Note to apply them the skin:set_skin() shou
|
|||||||
|
|
||||||
Could be redefined for dynamic texture generation
|
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
|
||||||
|
|
||||||
|
##skin:get_hand()
|
||||||
|
Get hand node
|
||||||
|
|
||||||
## skin:set_preview(texture)
|
## skin:set_preview(texture)
|
||||||
Set the skin preview - usually at the init time only
|
Set the skin preview - usually at the init time only
|
||||||
|
|
||||||
|
@ -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
|
- 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
|
- Full [3d_armor](https://forum.minetest.net/viewtopic.php?t=4654) support
|
||||||
- Compatible to 1.0 and 1.8 Minecraft skins format
|
- Compatible to 1.0 and 1.8 Minecraft skins format
|
||||||
|
- Skinned hand in 1st person view (1.0 skins only)
|
||||||
|
|
||||||
|
|
||||||
## Installing skins
|
## Installing skins
|
||||||
@ -53,6 +54,7 @@ The Script will download all the skins from the database for you.
|
|||||||
## License:
|
## License:
|
||||||
- GPLv3
|
- GPLv3
|
||||||
- skin texture licenses: See "meta" folder
|
- skin texture licenses: See "meta" folder
|
||||||
|
- hand model: CC0
|
||||||
|
|
||||||
### Credits
|
### Credits
|
||||||
|
|
||||||
@ -62,3 +64,4 @@ The Script will download all the skins from the database for you.
|
|||||||
- Krock (source code)
|
- Krock (source code)
|
||||||
- bell07 (source code)
|
- bell07 (source code)
|
||||||
- stujones11 (player models)
|
- stujones11 (player models)
|
||||||
|
- jordan4ibanez (1st person view hand)
|
||||||
|
1
init.lua
1
init.lua
@ -91,4 +91,5 @@ if not default_skin_obj then
|
|||||||
default_skin_obj:set_meta("format", '1.0')
|
default_skin_obj:set_meta("format", '1.0')
|
||||||
default_skin_obj:set_meta("_sort_id", 0)
|
default_skin_obj:set_meta("_sort_id", 0)
|
||||||
default_skin_obj:set_meta("name", "Sam")
|
default_skin_obj:set_meta("name", "Sam")
|
||||||
|
default_skin_obj:set_hand_from_texture()
|
||||||
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,33 @@ function skin_class:get_texture()
|
|||||||
return self._texture
|
return self._texture
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function skin_class:set_hand(hand)
|
||||||
|
self._hand = hand
|
||||||
|
end
|
||||||
|
|
||||||
|
function skin_class:set_hand_from_texture()
|
||||||
|
local hand = core.get_current_modname()..':'..self._texture:gsub('[%p%c%s]', '')
|
||||||
|
|
||||||
|
minetest.register_node(hand, {
|
||||||
|
tiles = {self:get_texture()},
|
||||||
|
inventory_image = "wieldhand.png",
|
||||||
|
visual_scale = 1,
|
||||||
|
wield_scale = {x=1,y=1,z=1},
|
||||||
|
paramtype = "light",
|
||||||
|
drawtype = "mesh",
|
||||||
|
mesh = "skinsdb_hand.b3d",
|
||||||
|
use_texture_alpha = "clip",
|
||||||
|
node_placement_prediction = "",
|
||||||
|
groups = { not_in_creative_inventory = 1 }
|
||||||
|
})
|
||||||
|
|
||||||
|
self:set_hand(hand)
|
||||||
|
end
|
||||||
|
|
||||||
|
function skin_class:get_hand()
|
||||||
|
return self._hand
|
||||||
|
end
|
||||||
|
|
||||||
function skin_class:set_preview(value)
|
function skin_class:set_preview(value)
|
||||||
self._preview = value
|
self._preview = value
|
||||||
end
|
end
|
||||||
@ -174,6 +201,14 @@ function skin_class:apply_skin_to_player(player)
|
|||||||
y = self:get_meta("visual_size_y") or 1
|
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
|
end
|
||||||
|
|
||||||
function skin_class:set_skin(player)
|
function skin_class:set_skin(player)
|
||||||
|
@ -48,8 +48,12 @@ for _, fn in pairs(skins_dir_list) do
|
|||||||
skin_obj:set_meta("playername", playername)
|
skin_obj:set_meta("playername", playername)
|
||||||
end
|
end
|
||||||
local file = io.open(skins.modpath.."/textures/"..fn, "r")
|
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()
|
file:close()
|
||||||
|
if skin_format == "1.0" then
|
||||||
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user