nc_skins-cd2025/skin_wieldhand.lua
Aaron Suen 2ba34c454e Initial skins mod based on NCC server mod
- Currently all skins must be pre-loaded into the mod texture
  folder at startup time; server restart required to change a
  player skin.
- Currently has partial support for the wieldhand (uninjured only)
- Some configuration added (adjustable rescaling, optional priv)
2021-07-27 07:01:18 -04:00

35 lines
995 B
Lua

-- LUALOCALS < ---------------------------------------------------------
local minetest, pairs
= minetest, pairs
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local api = _G[modname]
local hands = {}
for pname, texture in pairs(api.all_loaded_skins()) do
local hname = modname .. ":hand_" .. minetest.sha1(pname)
hands[pname] = hname
minetest.register_node(hname, {
drawtype = "mesh",
mesh = "nc_player_hand.obj",
tiles = {texture},
use_texture_alpha = "clip",
wield_scale = {x = 2, y = 2, z = 2},
virtual_item = true,
on_punch = minetest.remove_node
})
end
minetest.register_on_joinplayer(function(player)
local pname = player:get_player_name()
local hand = hands[pname]
if not hand then return end
minetest.after(0, function()
player = minetest.get_player_by_name(pname)
if not player then return end
player:get_inventory():set_stack("hand", 1, hand)
end)
end)