1
0
Fork 0

Add player skin support, add female skin

This commit is contained in:
Wuzzy 2019-03-05 00:11:43 +01:00
parent c19e3f455c
commit 62e3a8b9ff
15 changed files with 436 additions and 0 deletions

View File

@ -0,0 +1,3 @@
mcl_player
intllib?
3d_armor?

View File

@ -0,0 +1 @@
Mod that allows players to set their individual skins.

View File

@ -0,0 +1,148 @@
-- Simple Skins mod for Minetest (MineClone 2 Edition)
-- Released by TenPlus1 and based on Zeg9's code under MIT license
skins = {
skins = {}, meta = {},
modpath = minetest.get_modpath("simple_skins"),
skin_count = 0, -- counter of _custom_ skins (all skins except character.png)
}
-- Load support for intllib.
local S, NS = dofile(skins.modpath .. "/intllib.lua")
-- load skin list and metadata
local id, f, data, skin = 1
while true do
skin = "character_" .. id
-- does skin file exist ?
f = io.open(skins.modpath .. "/textures/" .. skin .. ".png")
-- escape loop if not found and remove last entry
if not f then
id = id - 1
break
end
f:close()
-- does metadata exist for that skin file ?
f = io.open(skins.modpath .. "/meta/" .. skin .. ".txt")
if f then
data = minetest.deserialize("return {" .. f:read('*all') .. "}")
f:close()
end
-- add metadata to list
skins.meta[skin] = {
name = data and data.name or "",
author = data and data.author or "",
}
id = id + 1
skins.skin_count = skins.skin_count + 1
end
skins.set_player_skin = function(player, skin)
if not player then
return
end
local playername = player:get_player_name()
skins.skins[playername] = skin
player:set_attribute("simple_skins:skin", skins.skins[playername])
skins.update_player_skin(player)
if minetest.get_modpath("3d_armor") then
armor.textures[playername].skin = skin .. ".png"
armor:update_player_visuals(player)
end
end
skins.update_player_skin = function(player)
if not player then
return
end
local playername = player:get_player_name()
mcl_player.player_set_textures(player, { skins.skins[playername] .. ".png" })
end
-- load player skin on join
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
local skin = player:get_attribute("simple_skins:skin")
local set_skin
-- do we already have a skin in player attributes?
if skin then
set_skin = skin
-- otherwise use random skin if not set
else
local r = math.random(0, skins.skin_count)
if r == 0 then
set_skin = "character"
else
set_skin = "character_" .. r
end
end
if set_skin then
skins.set_player_skin(player, set_skin)
end
end)
-- command to set player skin (usually for custom skins)
minetest.register_chatcommand("setskin", {
params = "[<player>] <skin number>",
description = S("Select player skin of yourself or another player"),
privs = {},
func = function(name, param)
local playername, skin_id = string.match(param, "([^ ]+) (%d+)")
if not playername or not skin_id then
skin_id = string.match(param, "(%d+)")
if not skin_id then
return false, S("Insufficient or wrong parameters")
end
playername = name
end
skin_id = tonumber(skin_id)
local player = minetest.get_player_by_name(playername)
if not player then
return false, S("Player @1 not online!", playername)
end
if name ~= playername then
local privs = minetest.get_player_privs(name)
if not privs.server then
return false, S("You need the “server” privilege to change the skin of other players!")
end
end
local skin
if skin_id == nil or skin_id > skins.skin_count or skin_id < 0 then
return false, S("Invalid skin number! Valid numbers: 0 to @1", skins.skin_count)
elseif skin_id == 0 then
skin = "character"
else
skin = "character_" .. tostring(skin_id)
end
skins.set_player_skin(player, skin)
local skinfile = skin..".png"
local your_msg = S("Your skin has been set to: @1", skinfile)
if name == playername then
return true, your_msg
else
minetest.chat_send_player(playername, your_msg)
return true, S("Skin of @1 set to: @2", playername, skinfile)
end
end,
})

View File

@ -0,0 +1,45 @@
-- Fallback functions for when `intllib` is not installed.
-- Code released under Unlicense <http://unlicense.org>.
-- Get the latest version of this file at:
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
local function format(str, ...)
local args = { ... }
local function repl(escape, open, num, close)
if escape == "" then
local replacement = tostring(args[tonumber(num)])
if open == "" then
replacement = replacement..close
end
return replacement
else
return "@"..open..num..close
end
end
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
end
local gettext, ngettext
if minetest.get_modpath("intllib") then
if intllib.make_gettext_pair then
-- New method using gettext.
gettext, ngettext = intllib.make_gettext_pair()
else
-- Old method using text files.
gettext = intllib.Getter()
end
end
-- Fill in missing functions.
gettext = gettext or function(msgid, ...)
return format(msgid, ...)
end
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
return format(n==1 and msgid or msgid_plural, ...)
end
return gettext, ngettext

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 TenPlus1
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,51 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-29 07:11+0200\n"
"PO-Revision-Date: 2017-07-29 07:17+0200\n"
"Last-Translator: fat115 <fat115@framasoft.org>\n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.12\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: init.lua
msgid "Select Player Skin:"
msgstr "Sélectionner l'apparence du joueur :"
#: init.lua
msgid "Name: "
msgstr "Nom : "
#: init.lua
msgid "Author: "
msgstr "Auteur : "
#: init.lua
msgid "Admin command to set player skin"
msgstr "Commande admin pour définir l'apparence du joueur"
#: init.lua
msgid "'s skin set to"
msgstr ", apparence définie pour"
#: init.lua
msgid "Set player skin"
msgstr "Définir l'apparence du joueur"
#: init.lua
msgid "Close"
msgstr "Fermer"
#: init.lua
msgid "[MOD] Simple Skins loaded"
msgstr "[MOD] Simple Skins chargé"

View File

@ -0,0 +1,52 @@
# simple_skin <italian translate>.
# Copyright (C) 2018
# This file is distributed under the same license as the PACKAGE package.
# Stefano Peris <xenon77.dev@gmail.com>, 2018.
# Github: <https://github.com/XenonCoder>
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-21 07:29+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Stefano Peris <xenon77.dev@gmail.com>\n"
"Language-Team: \n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.12\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: init.lua
msgid "Select Player Skin:"
msgstr "Seleziona la skin del giocatore"
#: init.lua
msgid "Name: "
msgstr "Nome"
#: init.lua
msgid "Author: "
msgstr "Autore"
#: init.lua
msgid "Admin command to set player skin"
msgstr "Comando di admin per impostare la skin del giocatore"
#: init.lua
msgid "'s skin set to"
msgstr ", la skin è impostata su"
#: init.lua
msgid "Set player skin"
msgstr "Imposta la skin del giocatore"
#: init.lua
msgid "Close"
msgstr "Chiudi"
#: init.lua
msgid "[MOD] Simple Skins loaded"
msgstr "[MOD] Skins semplici caricate"

View File

@ -0,0 +1,51 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-29 07:11+0200\n"
"PO-Revision-Date: 2018-02-14 01:23+0800\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.6\n"
"Last-Translator: MuhdNurHidayat (MNH48) <mnh48mail@gmail.com>\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"Language: ms\n"
#: init.lua
msgid "Select Player Skin:"
msgstr "Pilih Kulit Pemain:"
#: init.lua
msgid "Name: "
msgstr "Nama: "
#: init.lua
msgid "Author: "
msgstr "Pencipta: "
#: init.lua
msgid "Admin command to set player skin"
msgstr "Perintah pentadbir untuk menetapkan kulit pemain"
#: init.lua
msgid "'s skin set to"
msgstr " telah ditukarkan kulitnya kepada"
#: init.lua
msgid "Set player skin"
msgstr "Tetapkan kulit pemain"
#: init.lua
msgid "Close"
msgstr "Tutup"
#: init.lua
msgid "[MOD] Simple Skins loaded"
msgstr "[MODS] Simple Skins telah dimuatkan"

View File

@ -0,0 +1,50 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-29 07:11+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: init.lua
msgid "Select Player Skin:"
msgstr ""
#: init.lua
msgid "Name: "
msgstr ""
#: init.lua
msgid "Author: "
msgstr ""
#: init.lua
msgid "Admin command to set player skin"
msgstr ""
#: init.lua
msgid "'s skin set to"
msgstr ""
#: init.lua
msgid "Set player skin"
msgstr ""
#: init.lua
msgid "Close"
msgstr ""
#: init.lua
msgid "[MOD] Simple Skins loaded"
msgstr ""

View File

@ -0,0 +1,3 @@
name = "Steve",
author = "(Texture pack author)",
description = "The default male skin.",

View File

@ -0,0 +1,3 @@
name = "Alex",
author = "(Texture pack author)",
description = "The default female skin.",

View File

@ -0,0 +1 @@
name = simple_skins

View File

@ -0,0 +1,7 @@
Simple Skins, MineClone 2 Edition
Simple Skins mod to allow players to select a skin.
Use the chat command /setskin to change skin.
Original mod:
https://forum.minetest.net/viewtopic.php?id=9100

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB