mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-24 20:03:45 +01:00
Add mesh hand
This commit is contained in:
parent
62eaf60938
commit
9a54383a23
9
mods/PLAYER/mcl_meshhand/README.md
Normal file
9
mods/PLAYER/mcl_meshhand/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
Mesh hand mod for MineClone 2.
|
||||
|
||||
This mod uses a better-looking mesh for the wieldhand and applies the player skin texture to it.
|
||||
|
||||
== Credits ==
|
||||
Based on 3D Hand [newhand] mod by jordan4ibanez.
|
||||
https://forum.minetest.net/viewtopic.php?t=16435
|
||||
|
||||
License: CC0
|
1
mods/PLAYER/mcl_meshhand/depends.txt
Normal file
1
mods/PLAYER/mcl_meshhand/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
mcl_skins?
|
1
mods/PLAYER/mcl_meshhand/description.txt
Normal file
1
mods/PLAYER/mcl_meshhand/description.txt
Normal file
@ -0,0 +1 @@
|
||||
Applies the player skin texture to the hand.
|
47
mods/PLAYER/mcl_meshhand/init.lua
Normal file
47
mods/PLAYER/mcl_meshhand/init.lua
Normal file
@ -0,0 +1,47 @@
|
||||
local has_mcl_skins = minetest.get_modpath("mcl_skins") ~= nil
|
||||
|
||||
-- mcl_skins is enabled
|
||||
if has_mcl_skins == true then
|
||||
--generate a node for every skin
|
||||
for _,texture in pairs(mcl_skins.list) do
|
||||
minetest.register_node("mcl_meshhand:"..texture, {
|
||||
description = "",
|
||||
tiles = {texture..".png"},
|
||||
inventory_image = "blank.png",
|
||||
visual_scale = 1,
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
paramtype = "light",
|
||||
drawtype = "mesh",
|
||||
mesh = "mcl_meshhand.b3d",
|
||||
node_placement_prediction = "",
|
||||
})
|
||||
end
|
||||
--change the player's hand to their skin
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local skin = mcl_skins.skins[player:get_player_name()]
|
||||
player:get_inventory():set_stack("hand", 1, "mcl_meshhand:"..skin)
|
||||
end)
|
||||
|
||||
mcl_skins.register_on_set_skin(function(player, skin)
|
||||
local name = player:get_player_name()
|
||||
player:get_inventory():set_stack("hand", 1, "mcl_meshhand:"..skin)
|
||||
end)
|
||||
|
||||
--do default skin if no skin mod installed
|
||||
else
|
||||
minetest.register_node("mcl_meshhand:hand", {
|
||||
description = "",
|
||||
tiles = {"character.png"},
|
||||
inventory_image = "blank.png",
|
||||
visual_scale = 1,
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
paramtype = "light",
|
||||
drawtype = "mesh",
|
||||
mesh = "mcl_meshhand.b3d",
|
||||
node_placement_prediction = "",
|
||||
})
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
player:get_inventory():set_stack("hand", 1, "mcl_meshhand:hand")
|
||||
end)
|
||||
end
|
1
mods/PLAYER/mcl_meshhand/mod.conf
Normal file
1
mods/PLAYER/mcl_meshhand/mod.conf
Normal file
@ -0,0 +1 @@
|
||||
name = mcl_meshhand
|
BIN
mods/PLAYER/mcl_meshhand/models/mcl_meshhand.b3d
Normal file
BIN
mods/PLAYER/mcl_meshhand/models/mcl_meshhand.b3d
Normal file
Binary file not shown.
BIN
mods/PLAYER/mcl_meshhand/models/mcl_meshhand.blend
Normal file
BIN
mods/PLAYER/mcl_meshhand/models/mcl_meshhand.blend
Normal file
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
-- Skins for MineClone 2
|
||||
|
||||
mcl_skins = {
|
||||
skins = {}, previews = {}, meta = {},
|
||||
skins = {}, list = {}, previews = {}, meta = {},
|
||||
modpath = minetest.get_modpath("mcl_skins"),
|
||||
skin_count = 0, -- counter of _custom_ skins (all skins except character.png)
|
||||
}
|
||||
@ -14,6 +14,8 @@ local S, NS = dofile(mcl_skins.modpath .. "/intllib.lua")
|
||||
-- load skin list and metadata
|
||||
local id, f, data, skin = 1
|
||||
|
||||
mcl_skins.list[0] = "character"
|
||||
|
||||
while true do
|
||||
|
||||
skin = "character_" .. id
|
||||
@ -23,11 +25,13 @@ while true do
|
||||
|
||||
-- escape loop if not found and remove last entry
|
||||
if not f then
|
||||
mcl_skins.list[id] = nil
|
||||
id = id - 1
|
||||
break
|
||||
end
|
||||
|
||||
f:close()
|
||||
table.insert(mcl_skins.list, skin)
|
||||
|
||||
-- does metadata exist for that skin file ?
|
||||
f = io.open(mcl_skins.modpath .. "/meta/" .. skin .. ".txt")
|
||||
@ -52,7 +56,7 @@ mcl_skins.set_player_skin = function(player, skin_id)
|
||||
return false
|
||||
end
|
||||
local playername = player:get_player_name()
|
||||
local skin, preview
|
||||
local skin, skin_file, preview
|
||||
if skin_id == nil or type(skin_id) ~= "number" or skin_id < 0 or skin_id > mcl_skins.skin_count then
|
||||
return false
|
||||
elseif skin_id == 0 then
|
||||
@ -62,17 +66,21 @@ mcl_skins.set_player_skin = function(player, skin_id)
|
||||
skin = "character_" .. tostring(skin_id)
|
||||
preview = "player_" .. tostring(skin_id)
|
||||
end
|
||||
skin_file = skin .. ".png"
|
||||
mcl_skins.skins[playername] = skin
|
||||
mcl_skins.previews[playername] = preview
|
||||
player:set_attribute("mcl_skins:skin_id", tostring(skin_id))
|
||||
mcl_skins.update_player_skin(player)
|
||||
if minetest.get_modpath("3d_armor") then
|
||||
armor.textures[playername].skin = skin .. ".png"
|
||||
armor.textures[playername].skin = skin_file
|
||||
armor:update_player_visuals(player)
|
||||
end
|
||||
if minetest.get_modpath("mcl_inventory") then
|
||||
mcl_inventory.update_inventory_formspec(player)
|
||||
end
|
||||
for i=1, #mcl_skins.registered_on_set_skins do
|
||||
mcl_skins.registered_on_set_skins[i](player, skin)
|
||||
end
|
||||
minetest.log("action", "[mcl_skins] Player skin for "..playername.." set to skin #"..skin_id)
|
||||
return true
|
||||
end
|
||||
@ -108,6 +116,12 @@ minetest.register_on_joinplayer(function(player)
|
||||
end
|
||||
end)
|
||||
|
||||
mcl_skins.registered_on_set_skins = {}
|
||||
|
||||
mcl_skins.register_on_set_skin = function(func)
|
||||
table.insert(mcl_skins.registered_on_set_skins, func)
|
||||
end
|
||||
|
||||
-- command to set player skin (usually for custom skins)
|
||||
minetest.register_chatcommand("setskin", {
|
||||
params = "[<player>] <skin number>",
|
||||
|
Loading…
Reference in New Issue
Block a user