From e435d9c1ad1aca0b27952909d07c5e3caf09957e Mon Sep 17 00:00:00 2001 From: Milan* Date: Thu, 12 Jan 2017 22:08:01 +0100 Subject: [PATCH] pre-add playerskins mod --- mods/playerskins/depends.txt | 1 + mods/playerskins/init.lua | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 mods/playerskins/depends.txt create mode 100644 mods/playerskins/init.lua diff --git a/mods/playerskins/depends.txt b/mods/playerskins/depends.txt new file mode 100644 index 00000000..331d858c --- /dev/null +++ b/mods/playerskins/depends.txt @@ -0,0 +1 @@ +default \ No newline at end of file diff --git a/mods/playerskins/init.lua b/mods/playerskins/init.lua new file mode 100644 index 00000000..0134a2f8 --- /dev/null +++ b/mods/playerskins/init.lua @@ -0,0 +1,36 @@ +-- thanks for the support from tenplus1, kaeza and Shara <3 +-- +-- this is a kind of pre-version of the Illuna skinmod. +-- it is supposed to work together with a skinserver later. +-- since it is very basic and kindly rewritten by tenplus1, +-- i didn't yet decide about any license and so on. + +-- get mod textures path +local path = minetest.get_modpath("playerskins") .. "/textures/" + +-- this function runs every time player joins game +minetest.register_on_joinplayer(function(player) + + -- get player name from player object + local name = player:get_player_name() + + -- make name lower case and add .png extension + name = name:lower() .. ".png" + + -- set skin to default + local skin = "character.png" + + -- check if texture exists and set new skin + local f = io.open(path .. name, "r") + if f then + skin = name -- set new skin name + f:close() -- close file + + -- apply player texture + minetest.after(1, function() + player:set_properties({ + textures = {skin}, + }) + end) + end +end)