5 Commits

Author SHA1 Message Date
da6905fd02 Mention i3 support (#55) 2021-01-03 09:36:20 +01:00
8048cb08f1 change default dependency to player_api 2020-09-22 16:03:00 +02:00
77c00a0823 update_skins.py
Remove leading zeros again
2020-09-10 14:25:01 +02:00
8799ba0bd5 updater/update_skins.py: Do not download preview files by default 2020-09-10 14:25:01 +02:00
b5ba66deca api.lua: Fix deprecation warnings 2020-07-29 20:27:09 +02:00
4 changed files with 43 additions and 30 deletions

View File

@ -9,6 +9,7 @@ This Minetest mod offers changeable player skins with a graphical interface for
- Skin change menu for sfinv (in minetest_game) and [unified_inventory](https://forum.minetest.net/viewtopic.php?t=12767)
- Skins change menu and command line using chat command /skinsdb (set | show | list | list private | list public | ui)
- Supported by [smart_inventory](https://forum.minetest.net/viewtopic.php?t=16597) for the skin selection
- Supported by [i3](https://github.com/minetest-mods/i3) inventory mod
- Skin previews supported in selection
- Additional information for each skin
- Support for different skins lists: public and a per-player list are currently implemented

View File

@ -2,9 +2,11 @@
local storage = minetest.get_mod_storage()
function skins.get_player_skin(player)
if player:get_attribute("skinsdb:skin_key") then
storage:set_string(player:get_player_name(), player:get_attribute("skinsdb:skin_key"))
player:set_attribute("skinsdb:skin_key", nil)
local meta = player:get_meta()
if meta:get("skinsdb:skin_key") then
-- Move player data prior July 2018 to mod storage
storage:set_string(player:get_player_name(), player:get_string("skinsdb:skin_key"))
meta:set_string("skinsdb:skin_key", "")
end
local skin = storage:get_string(player:get_player_name())
return skins.get(skin) or skins.get(skins.default)

View File

@ -1,4 +1,4 @@
name = skinsdb
description = Player skin mod, supporting unified_inventory, sfinv and smart_inventory
depends = default
depends = player_api
optional_depends = unified_inventory,3d_armor,clothing,sfinv

View File

@ -1,5 +1,8 @@
import sys, requests, base64
download_preview = ( len (sys.argv) > 1 and sys.argv[1] == "with_preview" )
print("Downloading skins from minetest.fensta.bplaced.net ...")
# Requesting all skins and their raw texture using the API
r = requests.get('http://minetest.fensta.bplaced.net/api/v2/get.json.php?getlist&page=1&per_page=999999999')
@ -10,35 +13,42 @@ if r.status_code != 200:
data = r.json()
count = 0
print("Writing to file and downloading previews ...")
if download_preview:
print("Writing to file and downloading previews ...")
else:
print("Writing skins")
for json in data["skins"]:
id = str(json["id"])
# Downloading the preview of the skin
r2 = requests.get('http://minetest.fensta.bplaced.net/skins/1/' + id + ".png")
if r.status_code == 200:
preview = r2.content
# Read meta datas
name = str(json["name"])
author = str(json["author"])
license = str(json["license"])
# Texture file
raw_data = base64.b64decode(json["img"])
file = open("../textures/character_" + id + ".png", "wb")
file.write(bytearray(raw_data))
file.close()
# Preview file
file = open("../textures/character_" + id + "_preview.png", "wb")
file.write(bytearray(preview))
file.close()
# Meta file
file = open("../meta/character_" + id + ".txt", "w")
file.write(name + "\n" + author + "\n" + license + "\n")
file.close()
print("Added #%s Name: %s Author: %s License: %s" % (id, name, author, license))
count += 1
else:
print("Failed to download skin #" + id)
# Texture file
raw_data = base64.b64decode(json["img"])
file = open("../textures/character_" + id + ".png", "wb")
file.write(bytearray(raw_data))
file.close()
# Meta file
name = str(json["name"])
author = str(json["author"])
license = str(json["license"])
file = open("../meta/character_" + id + ".txt", "w")
file.write(name + "\n" + author + "\n" + license + "\n")
file.close()
print("Added #%s Name: %s Author: %s License: %s" % (id, name, author, license))
count += 1
if download_preview:
# Downloading the preview of the skin
r2 = requests.get('http://minetest.fensta.bplaced.net/skins/1/' + id + ".png")
if r2.status_code == 200:
# Preview file
preview = r2.content
file = open("../textures/character_" + id + "_preview.png", "wb")
file.write(bytearray(preview))
file.close()
else:
print("Failed to download skin preview #" + id)
print("Fetched " + str(count) + " skins!")