forked from mtcontrib/minetest-u_skinsdb
Add hacky skin preview, update README
This commit is contained in:
parent
0e84c6cc47
commit
597213a67d
9
README
9
README
|
@ -8,11 +8,12 @@ https://github.com/minetest-technic/unified_inventory
|
||||||
|
|
||||||
This is the "u_skindb" branch, it is ment to download the skins from addi's skin database (http://minetest.fensta.bplaced.net).
|
This is the "u_skindb" branch, it is ment to download the skins from addi's skin database (http://minetest.fensta.bplaced.net).
|
||||||
|
|
||||||
To re-download the latest skins you may want to run:
|
To re-download the latest skins you have 2 ways:
|
||||||
"./update_from_db.py" OR
|
1, if you have blender) Run the script "update_from_db.py" OR "update_from_db2.py"
|
||||||
"./update_from_db2.py"
|
and then "./generate_previews.sh"
|
||||||
script, then "./generate_previews.sh" before using the mod.
|
|
||||||
|
|
||||||
|
2, if you are lazy) Run the script "update_from_db_hacky.py"
|
||||||
|
and then make sure, you have set "u_skins.used_hacky" to "true" in "./u_skins/init.lua"
|
||||||
|
|
||||||
Credits:
|
Credits:
|
||||||
MirceaKitsune (WTFPL) + bundled script by Zeg9 (WTFPL too):
|
MirceaKitsune (WTFPL) + bundled script by Zeg9 (WTFPL too):
|
||||||
|
|
|
@ -6,6 +6,7 @@ u_skins = {}
|
||||||
u_skins.type = { SPRITE=0, MODEL=1 }
|
u_skins.type = { SPRITE=0, MODEL=1 }
|
||||||
u_skins.pages = {}
|
u_skins.pages = {}
|
||||||
u_skins.u_skins = {}
|
u_skins.u_skins = {}
|
||||||
|
u_skins.used_hacky = false -- set to true if used hacky way to update skins
|
||||||
|
|
||||||
u_skins.get_type = function(texture)
|
u_skins.get_type = function(texture)
|
||||||
if not texture then return end
|
if not texture then return end
|
||||||
|
@ -34,6 +35,7 @@ u_skins.update_player_skin = function(player)
|
||||||
elseif u_skins.get_type(u_skins.u_skins[name]) == u_skins.type.MODEL then
|
elseif u_skins.get_type(u_skins.u_skins[name]) == u_skins.type.MODEL then
|
||||||
player:set_properties({
|
player:set_properties({
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
|
mesh = "character.x",
|
||||||
textures = {u_skins.u_skins[name]..".png"},
|
textures = {u_skins.u_skins[name]..".png"},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
})
|
})
|
||||||
|
@ -47,11 +49,13 @@ unified_inventory.register_page("u_skins", {
|
||||||
name = player:get_player_name()
|
name = player:get_player_name()
|
||||||
local formspec = "background[0.06,0.99;7.92,7.52;ui_misc_form.png]"
|
local formspec = "background[0.06,0.99;7.92,7.52;ui_misc_form.png]"
|
||||||
if u_skins.get_type(u_skins.u_skins[name]) == u_skins.type.MODEL then
|
if u_skins.get_type(u_skins.u_skins[name]) == u_skins.type.MODEL then
|
||||||
formspec = formspec
|
formspec = formspec.."image[0,.75;1,2;"..u_skins.u_skins[name].."_preview.png]"
|
||||||
.. "image[0,.75;1,2;"..u_skins.u_skins[name].."_preview.png]"
|
if not u_skins.used_hacky then
|
||||||
.. "image[1,.75;1,2;"..u_skins.u_skins[name].."_preview_back.png]"
|
-- player back view
|
||||||
.. "label[6,.5;Raw texture:]"
|
formspec = formspec.."image[1,.75;1,2;"..u_skins.u_skins[name].."_preview_back.png]"
|
||||||
.. "image[6,1;2,1;"..u_skins.u_skins[name]..".png]"
|
end
|
||||||
|
formspec = formspec.."label[6,.5;Raw texture:]"
|
||||||
|
.."image[6,1;2,1;"..u_skins.u_skins[name]..".png]"
|
||||||
|
|
||||||
else
|
else
|
||||||
formspec = formspec
|
formspec = formspec
|
||||||
|
|
59
update_from_db_hacky.py
Normal file
59
update_from_db_hacky.py
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
from http.client import HTTPConnection
|
||||||
|
import json
|
||||||
|
import base64
|
||||||
|
|
||||||
|
server = "minetest.fensta.bplaced.net"
|
||||||
|
skinsdir = "u_skins/textures/"
|
||||||
|
metadir = "u_skins/meta/"
|
||||||
|
i = 1
|
||||||
|
pages = 0
|
||||||
|
|
||||||
|
c = HTTPConnection(server)
|
||||||
|
def addpage(page):
|
||||||
|
global i, pages
|
||||||
|
print( "Page: "+str(page))
|
||||||
|
try:
|
||||||
|
c.request("GET","/api/get.json.php?getlist&page="+str(page)+"&outformat=base64")
|
||||||
|
r = c.getresponse()
|
||||||
|
except StandardError:
|
||||||
|
c.request("GET","/api/get.json.php?getlist&page="+str(page)+"&outformat=base64")
|
||||||
|
r = c.getresponse()
|
||||||
|
if r.status != 200:
|
||||||
|
print("Error", r.status)
|
||||||
|
exit(r.status)
|
||||||
|
data = r.read().decode()
|
||||||
|
l = json.loads(data)
|
||||||
|
if not l["success"]:
|
||||||
|
print("Success != True")
|
||||||
|
exit(1)
|
||||||
|
pages = int(l["pages"])
|
||||||
|
for s in l["skins"]:
|
||||||
|
f = open(skinsdir+"character_"+str(i)+".png",'wb')
|
||||||
|
f.write(base64.b64decode(s["img"]))
|
||||||
|
f.close()
|
||||||
|
f = open(metadir+"character_"+str(i)+".txt",'w')
|
||||||
|
f.write('name = "'+s["name"]+'",\n')
|
||||||
|
f.write('author = "'+s["author"]+'",\n')
|
||||||
|
f.write('comment = "'+s["license"]+'",\n')
|
||||||
|
f.close()
|
||||||
|
try:
|
||||||
|
c.request("GET","/skins/1/"+str(s["id"])+".png")
|
||||||
|
r = c.getresponse()
|
||||||
|
except StandardError:
|
||||||
|
c.request("GET","/skins/1/"+str(s["id"])+".png")
|
||||||
|
r = c.getresponse()
|
||||||
|
if r.status != 200:
|
||||||
|
print("Error", r.status)
|
||||||
|
exit(r.status)
|
||||||
|
data = r.read()
|
||||||
|
f = open(skinsdir+"character_"+str(i)+"_preview.png",'wb')
|
||||||
|
f.write(data)
|
||||||
|
f.close()
|
||||||
|
i = i + 1
|
||||||
|
addpage(1)
|
||||||
|
if pages > 1:
|
||||||
|
for p in range(pages-1):
|
||||||
|
addpage(p+2)
|
||||||
|
print("Skins have been updated!")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user