forked from MineClone5/MineClone5
Rename simple_skins to mcl_skins
This commit is contained in:
parent
e47bd634d4
commit
aae30bba39
|
@ -66,7 +66,9 @@ armor = {
|
||||||
version = "0.4.6",
|
version = "0.4.6",
|
||||||
}
|
}
|
||||||
|
|
||||||
if minetest.get_modpath("skins") then
|
if minetest.get_modpath("mcl_skins") then
|
||||||
|
skin_mod = "mcl_skins"
|
||||||
|
elseif minetest.get_modpath("skins") then
|
||||||
skin_mod = "skins"
|
skin_mod = "skins"
|
||||||
elseif minetest.get_modpath("simple_skins") then
|
elseif minetest.get_modpath("simple_skins") then
|
||||||
skin_mod = "simple_skins"
|
skin_mod = "simple_skins"
|
||||||
|
@ -197,7 +199,9 @@ end
|
||||||
|
|
||||||
armor.get_player_skin = function(self, name)
|
armor.get_player_skin = function(self, name)
|
||||||
local skin = nil
|
local skin = nil
|
||||||
if skin_mod == "skins" or skin_mod == "simple_skins" then
|
if skin_mod == "mcl_skins" then
|
||||||
|
skin = mcl_skins.skins[name]
|
||||||
|
elseif skin_mod == "skins" or skin_mod == "simple_skins" then
|
||||||
skin = skins.skins[name]
|
skin = skins.skins[name]
|
||||||
elseif skin_mod == "u_skins" then
|
elseif skin_mod == "u_skins" then
|
||||||
skin = u_skins.u_skins[name]
|
skin = u_skins.u_skins[name]
|
||||||
|
@ -380,7 +384,12 @@ minetest.register_on_joinplayer(function(player)
|
||||||
wielditem = "3d_armor_trans.png",
|
wielditem = "3d_armor_trans.png",
|
||||||
preview = armor.default_skin.."_preview.png",
|
preview = armor.default_skin.."_preview.png",
|
||||||
}
|
}
|
||||||
if skin_mod == "skins" then
|
if skin_mod == "mcl_skins" then
|
||||||
|
local skin = mcl_skins.skins[name]
|
||||||
|
if skin then
|
||||||
|
armor.textures[name].skin = skin..".png"
|
||||||
|
end
|
||||||
|
elseif skin_mod == "skins" then
|
||||||
local skin = skins.skins[name]
|
local skin = skins.skins[name]
|
||||||
if skin and skins.get_type(skin) == skins.type.MODEL then
|
if skin and skins.get_type(skin) == skins.type.MODEL then
|
||||||
armor.textures[name].skin = skin..".png"
|
armor.textures[name].skin = skin..".png"
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
-- Released by TenPlus1 and based on Zeg9's code under MIT license
|
-- Released by TenPlus1 and based on Zeg9's code under MIT license
|
||||||
|
|
||||||
skins = {
|
mcl_skins = {
|
||||||
skins = {}, previews = {}, meta = {},
|
skins = {}, previews = {}, meta = {},
|
||||||
modpath = minetest.get_modpath("simple_skins"),
|
modpath = minetest.get_modpath("mcl_skins"),
|
||||||
skin_count = 0, -- counter of _custom_ skins (all skins except character.png)
|
skin_count = 0, -- counter of _custom_ skins (all skins except character.png)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S, NS = dofile(skins.modpath .. "/intllib.lua")
|
local S, NS = dofile(mcl_skins.modpath .. "/intllib.lua")
|
||||||
|
|
||||||
|
|
||||||
-- load skin list and metadata
|
-- load skin list and metadata
|
||||||
|
@ -21,7 +21,7 @@ while true do
|
||||||
skin = "character_" .. id
|
skin = "character_" .. id
|
||||||
|
|
||||||
-- does skin file exist ?
|
-- does skin file exist ?
|
||||||
f = io.open(skins.modpath .. "/textures/" .. skin .. ".png")
|
f = io.open(mcl_skins.modpath .. "/textures/" .. skin .. ".png")
|
||||||
|
|
||||||
-- escape loop if not found and remove last entry
|
-- escape loop if not found and remove last entry
|
||||||
if not f then
|
if not f then
|
||||||
|
@ -32,7 +32,7 @@ while true do
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- does metadata exist for that skin file ?
|
-- does metadata exist for that skin file ?
|
||||||
f = io.open(skins.modpath .. "/meta/" .. skin .. ".txt")
|
f = io.open(mcl_skins.modpath .. "/meta/" .. skin .. ".txt")
|
||||||
|
|
||||||
if f then
|
if f then
|
||||||
data = minetest.deserialize("return {" .. f:read('*all') .. "}")
|
data = minetest.deserialize("return {" .. f:read('*all') .. "}")
|
||||||
|
@ -40,22 +40,22 @@ while true do
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add metadata to list
|
-- add metadata to list
|
||||||
skins.meta[skin] = {
|
mcl_skins.meta[skin] = {
|
||||||
name = data and data.name or "",
|
name = data and data.name or "",
|
||||||
author = data and data.author or "",
|
author = data and data.author or "",
|
||||||
}
|
}
|
||||||
|
|
||||||
id = id + 1
|
id = id + 1
|
||||||
skins.skin_count = skins.skin_count + 1
|
mcl_skins.skin_count = mcl_skins.skin_count + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
skins.set_player_skin = function(player, skin_id)
|
mcl_skins.set_player_skin = function(player, skin_id)
|
||||||
if not player then
|
if not player then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
local skin, preview
|
local skin, preview
|
||||||
if skin_id == nil or type(skin_id) ~= "number" or skin_id < 0 or skin_id > skins.skin_count then
|
if skin_id == nil or type(skin_id) ~= "number" or skin_id < 0 or skin_id > mcl_skins.skin_count then
|
||||||
return false
|
return false
|
||||||
elseif skin_id == 0 then
|
elseif skin_id == 0 then
|
||||||
skin = "character"
|
skin = "character"
|
||||||
|
@ -64,10 +64,10 @@ skins.set_player_skin = function(player, skin_id)
|
||||||
skin = "character_" .. tostring(skin_id)
|
skin = "character_" .. tostring(skin_id)
|
||||||
preview = "player_" .. tostring(skin_id)
|
preview = "player_" .. tostring(skin_id)
|
||||||
end
|
end
|
||||||
skins.skins[playername] = skin
|
mcl_skins.skins[playername] = skin
|
||||||
skins.previews[playername] = preview
|
mcl_skins.previews[playername] = preview
|
||||||
player:set_attribute("simple_skins:skin_id", skin_id)
|
player:set_attribute("simple_skins:skin_id", skin_id)
|
||||||
skins.update_player_skin(player)
|
mcl_skins.update_player_skin(player)
|
||||||
if minetest.get_modpath("3d_armor") then
|
if minetest.get_modpath("3d_armor") then
|
||||||
armor.textures[playername].skin = skin .. ".png"
|
armor.textures[playername].skin = skin .. ".png"
|
||||||
armor:update_player_visuals(player)
|
armor:update_player_visuals(player)
|
||||||
|
@ -78,12 +78,12 @@ skins.set_player_skin = function(player, skin_id)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
skins.update_player_skin = function(player)
|
mcl_skins.update_player_skin = function(player)
|
||||||
if not player then
|
if not player then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
mcl_player.player_set_textures(player, { skins.skins[playername] .. ".png" }, skins.previews[playername] .. ".png" )
|
mcl_player.player_set_textures(player, { mcl_skins.skins[playername] .. ".png" }, mcl_skins.previews[playername] .. ".png" )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- load player skin on join
|
-- load player skin on join
|
||||||
|
@ -97,10 +97,10 @@ minetest.register_on_joinplayer(function(player)
|
||||||
set_skin = tonumber(skin_id)
|
set_skin = tonumber(skin_id)
|
||||||
-- otherwise use random skin if not set
|
-- otherwise use random skin if not set
|
||||||
else
|
else
|
||||||
set_skin = math.random(0, skins.skin_count)
|
set_skin = math.random(0, mcl_skins.skin_count)
|
||||||
end
|
end
|
||||||
if set_skin then
|
if set_skin then
|
||||||
skins.set_player_skin(player, set_skin)
|
mcl_skins.set_player_skin(player, set_skin)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -134,9 +134,9 @@ minetest.register_chatcommand("setskin", {
|
||||||
end
|
end
|
||||||
|
|
||||||
local skin
|
local skin
|
||||||
local ok = skins.set_player_skin(player, skin_id)
|
local ok = mcl_skins.set_player_skin(player, skin_id)
|
||||||
if not ok then
|
if not ok then
|
||||||
return false, S("Invalid skin number! Valid numbers: 0 to @1", skins.skin_count)
|
return false, S("Invalid skin number! Valid numbers: 0 to @1", mcl_skins.skin_count)
|
||||||
end
|
end
|
||||||
local skinfile = "Skin #"..skin_id
|
local skinfile = "Skin #"..skin_id
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
name = mcl_skins
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
@ -1 +0,0 @@
|
||||||
name = simple_skins
|
|
Loading…
Reference in New Issue