diff --git a/mods/PLAYER/simple_skins/depends.txt b/mods/PLAYER/simple_skins/depends.txt new file mode 100644 index 0000000000..1927ce890d --- /dev/null +++ b/mods/PLAYER/simple_skins/depends.txt @@ -0,0 +1,3 @@ +mcl_player +intllib? +3d_armor? diff --git a/mods/PLAYER/simple_skins/description.txt b/mods/PLAYER/simple_skins/description.txt new file mode 100644 index 0000000000..61c7bff643 --- /dev/null +++ b/mods/PLAYER/simple_skins/description.txt @@ -0,0 +1 @@ +Mod that allows players to set their individual skins. \ No newline at end of file diff --git a/mods/PLAYER/simple_skins/init.lua b/mods/PLAYER/simple_skins/init.lua new file mode 100644 index 0000000000..3a41490f4f --- /dev/null +++ b/mods/PLAYER/simple_skins/init.lua @@ -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 = "[] ", + 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, +}) diff --git a/mods/PLAYER/simple_skins/intllib.lua b/mods/PLAYER/simple_skins/intllib.lua new file mode 100644 index 0000000000..6669d72023 --- /dev/null +++ b/mods/PLAYER/simple_skins/intllib.lua @@ -0,0 +1,45 @@ + +-- Fallback functions for when `intllib` is not installed. +-- Code released under Unlicense . + +-- 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 diff --git a/mods/PLAYER/simple_skins/license.txt b/mods/PLAYER/simple_skins/license.txt new file mode 100644 index 0000000000..fec6f6aa51 --- /dev/null +++ b/mods/PLAYER/simple_skins/license.txt @@ -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. diff --git a/mods/PLAYER/simple_skins/locale/fr.po b/mods/PLAYER/simple_skins/locale/fr.po new file mode 100644 index 0000000000..30d8e36e74 --- /dev/null +++ b/mods/PLAYER/simple_skins/locale/fr.po @@ -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 , 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 \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é" diff --git a/mods/PLAYER/simple_skins/locale/it.po b/mods/PLAYER/simple_skins/locale/it.po new file mode 100644 index 0000000000..d4701316d5 --- /dev/null +++ b/mods/PLAYER/simple_skins/locale/it.po @@ -0,0 +1,52 @@ +# simple_skin . +# Copyright (C) 2018 +# This file is distributed under the same license as the PACKAGE package. +# Stefano Peris , 2018. +# Github: +# +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 \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" diff --git a/mods/PLAYER/simple_skins/locale/ms.po b/mods/PLAYER/simple_skins/locale/ms.po new file mode 100644 index 0000000000..bba5982d4a --- /dev/null +++ b/mods/PLAYER/simple_skins/locale/ms.po @@ -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 , 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) \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" diff --git a/mods/PLAYER/simple_skins/locale/template.pot b/mods/PLAYER/simple_skins/locale/template.pot new file mode 100644 index 0000000000..36282e43ce --- /dev/null +++ b/mods/PLAYER/simple_skins/locale/template.pot @@ -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 , 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 \n" +"Language-Team: LANGUAGE \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 "" diff --git a/mods/PLAYER/simple_skins/meta/character.txt b/mods/PLAYER/simple_skins/meta/character.txt new file mode 100644 index 0000000000..5a07db19e4 --- /dev/null +++ b/mods/PLAYER/simple_skins/meta/character.txt @@ -0,0 +1,3 @@ +name = "Steve", +author = "(Texture pack author)", +description = "The default male skin.", diff --git a/mods/PLAYER/simple_skins/meta/character_1.txt b/mods/PLAYER/simple_skins/meta/character_1.txt new file mode 100644 index 0000000000..ec43895505 --- /dev/null +++ b/mods/PLAYER/simple_skins/meta/character_1.txt @@ -0,0 +1,3 @@ +name = "Alex", +author = "(Texture pack author)", +description = "The default female skin.", diff --git a/mods/PLAYER/simple_skins/mod.conf b/mods/PLAYER/simple_skins/mod.conf new file mode 100644 index 0000000000..aff90aabee --- /dev/null +++ b/mods/PLAYER/simple_skins/mod.conf @@ -0,0 +1 @@ +name = simple_skins diff --git a/mods/PLAYER/simple_skins/readme.md b/mods/PLAYER/simple_skins/readme.md new file mode 100644 index 0000000000..0c6980bbb3 --- /dev/null +++ b/mods/PLAYER/simple_skins/readme.md @@ -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 diff --git a/mods/PLAYER/simple_skins/textures/character_1.png b/mods/PLAYER/simple_skins/textures/character_1.png new file mode 100644 index 0000000000..71f02471dc Binary files /dev/null and b/mods/PLAYER/simple_skins/textures/character_1.png differ diff --git a/mods/PLAYER/simple_skins/textures/inventory_plus_skins.png b/mods/PLAYER/simple_skins/textures/inventory_plus_skins.png new file mode 100644 index 0000000000..7cc97759cd Binary files /dev/null and b/mods/PLAYER/simple_skins/textures/inventory_plus_skins.png differ