mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2025-07-21 00:30:23 +02:00
Compare commits
5 Commits
1fcd3c4a8c
...
da6905fd02
Author | SHA1 | Date | |
---|---|---|---|
da6905fd02 | |||
8048cb08f1 | |||
77c00a0823 | |||
8799ba0bd5 | |||
b5ba66deca |
@ -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)
|
- 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)
|
- 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 [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
|
- Skin previews supported in selection
|
||||||
- Additional information for each skin
|
- Additional information for each skin
|
||||||
- Support for different skins lists: public and a per-player list are currently implemented
|
- Support for different skins lists: public and a per-player list are currently implemented
|
||||||
|
8
api.lua
8
api.lua
@ -2,9 +2,11 @@
|
|||||||
local storage = minetest.get_mod_storage()
|
local storage = minetest.get_mod_storage()
|
||||||
|
|
||||||
function skins.get_player_skin(player)
|
function skins.get_player_skin(player)
|
||||||
if player:get_attribute("skinsdb:skin_key") then
|
local meta = player:get_meta()
|
||||||
storage:set_string(player:get_player_name(), player:get_attribute("skinsdb:skin_key"))
|
if meta:get("skinsdb:skin_key") then
|
||||||
player:set_attribute("skinsdb:skin_key", nil)
|
-- 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
|
end
|
||||||
local skin = storage:get_string(player:get_player_name())
|
local skin = storage:get_string(player:get_player_name())
|
||||||
return skins.get(skin) or skins.get(skins.default)
|
return skins.get(skin) or skins.get(skins.default)
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,4 +1,4 @@
|
|||||||
name = skinsdb
|
name = skinsdb
|
||||||
description = Player skin mod, supporting unified_inventory, sfinv and smart_inventory
|
description = Player skin mod, supporting unified_inventory, sfinv and smart_inventory
|
||||||
depends = default
|
depends = player_api
|
||||||
optional_depends = unified_inventory,3d_armor,clothing,sfinv
|
optional_depends = unified_inventory,3d_armor,clothing,sfinv
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import sys, requests, base64
|
import sys, requests, base64
|
||||||
|
|
||||||
|
download_preview = ( len (sys.argv) > 1 and sys.argv[1] == "with_preview" )
|
||||||
|
|
||||||
|
|
||||||
print("Downloading skins from minetest.fensta.bplaced.net ...")
|
print("Downloading skins from minetest.fensta.bplaced.net ...")
|
||||||
# Requesting all skins and their raw texture using the API
|
# 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')
|
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()
|
data = r.json()
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
|
if download_preview:
|
||||||
print("Writing to file and downloading previews ...")
|
print("Writing to file and downloading previews ...")
|
||||||
|
else:
|
||||||
|
print("Writing skins")
|
||||||
|
|
||||||
|
|
||||||
for json in data["skins"]:
|
for json in data["skins"]:
|
||||||
id = str(json["id"])
|
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
|
# Texture file
|
||||||
raw_data = base64.b64decode(json["img"])
|
raw_data = base64.b64decode(json["img"])
|
||||||
file = open("../textures/character_" + id + ".png", "wb")
|
file = open("../textures/character_" + id + ".png", "wb")
|
||||||
file.write(bytearray(raw_data))
|
file.write(bytearray(raw_data))
|
||||||
file.close()
|
file.close()
|
||||||
# Preview file
|
|
||||||
file = open("../textures/character_" + id + "_preview.png", "wb")
|
|
||||||
file.write(bytearray(preview))
|
|
||||||
file.close()
|
|
||||||
# Meta file
|
# Meta file
|
||||||
|
name = str(json["name"])
|
||||||
|
author = str(json["author"])
|
||||||
|
license = str(json["license"])
|
||||||
file = open("../meta/character_" + id + ".txt", "w")
|
file = open("../meta/character_" + id + ".txt", "w")
|
||||||
file.write(name + "\n" + author + "\n" + license + "\n")
|
file.write(name + "\n" + author + "\n" + license + "\n")
|
||||||
file.close()
|
file.close()
|
||||||
print("Added #%s Name: %s Author: %s License: %s" % (id, name, author, license))
|
print("Added #%s Name: %s Author: %s License: %s" % (id, name, author, license))
|
||||||
count += 1
|
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:
|
else:
|
||||||
print("Failed to download skin #" + id)
|
print("Failed to download skin preview #" + id)
|
||||||
|
|
||||||
|
|
||||||
print("Fetched " + str(count) + " skins!")
|
print("Fetched " + str(count) + " skins!")
|
||||||
|
Reference in New Issue
Block a user