-
Notifications
You must be signed in to change notification settings - Fork 0
/
skin.lua
77 lines (68 loc) · 1.87 KB
/
skin.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
local player_api = rawget(_G, "player_api")
local nodecore = rawget(_G, "nodecore")
local function get_textures(player)
if player_api then
local anim = player_api.get_animation(player)
return anim.textures or player_api.registered_models[anim.model].textures
end
return player:get_properties().textures
end
local function get_texture(player, index)
return assert(get_textures(player)[index])
end
local function set_textures(player, textures)
if player_api then
player_api.set_textures(player, textures)
return
end
player:set_properties{textures = textures}
end
local function set_texture(player, index, texture)
local textures = modlib.table.copy(get_textures(player))
textures[index] = texture
set_textures(player, textures)
end
local skin_texture_index = 1
function epidermis.get_skin(player)
return get_texture(player, skin_texture_index)
end
local nc_skins = {}
if nodecore then
local player_skin = nodecore.player_skin
function nodecore.player_skin(player, ...)
return nc_skins[player:get_player_name()] or player_skin(player, ...)
end
end
function epidermis.set_skin(player, skin)
if nodecore then
nc_skins[player:get_player_name()] = skin
return
end
set_texture(player, skin_texture_index, skin)
end
function epidermis.get_model(player)
if player_api then
return player_api.get_animation(player).model
end
return player:get_properties().mesh
end
local nc_models = {}
if nodecore then
local player_visuals_base = nodecore.player_visuals_base
function nodecore.player_visuals_base(player)
local visuals = player_visuals_base(player)
visuals.mesh = nc_models[player:get_player_name()] or visuals.mesh
return visuals
end
end
function epidermis.set_model(player, model)
if player_api then
player_api.set_model(player, model)
return
end
if nodecore then
nc_models[player:get_player_name()] = model
return
end
player:set_properties{mesh = model}
end