summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README11
-rw-r--r--u_skins/init.lua14
-rw-r--r--update_from_db_hacky.py59
3 files changed, 74 insertions, 10 deletions
diff --git a/README b/README
index f3da950..c1f13b3 100644
--- a/README
+++ b/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).
-To re-download the latest skins you may want to run:
- "./update_from_db.py" OR
- "./update_from_db2.py"
- script, then "./generate_previews.sh" before using the mod.
-
+To re-download the latest skins you have 2 ways:
+ 1, if you have blender) Run the script "update_from_db.py" OR "update_from_db2.py"
+ and then "./generate_previews.sh"
+
+ 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:
MirceaKitsune (WTFPL) + bundled script by Zeg9 (WTFPL too):
diff --git a/u_skins/init.lua b/u_skins/init.lua
index abc73b0..5e3119b 100644
--- a/u_skins/init.lua
+++ b/u_skins/init.lua
@@ -6,6 +6,7 @@ u_skins = {}
u_skins.type = { SPRITE=0, MODEL=1 }
u_skins.pages = {}
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)
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
player:set_properties({
visual = "mesh",
+ mesh = "character.x",
textures = {u_skins.u_skins[name]..".png"},
visual_size = {x=1, y=1},
})
@@ -47,11 +49,13 @@ unified_inventory.register_page("u_skins", {
name = player:get_player_name()
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
- formspec = formspec
- .. "image[0,.75;1,2;"..u_skins.u_skins[name].."_preview.png]"
- .. "image[1,.75;1,2;"..u_skins.u_skins[name].."_preview_back.png]"
- .. "label[6,.5;Raw texture:]"
- .. "image[6,1;2,1;"..u_skins.u_skins[name]..".png]"
+ formspec = formspec.."image[0,.75;1,2;"..u_skins.u_skins[name].."_preview.png]"
+ if not u_skins.used_hacky then
+ -- player back view
+ formspec = formspec.."image[1,.75;1,2;"..u_skins.u_skins[name].."_preview_back.png]"
+ end
+ formspec = formspec.."label[6,.5;Raw texture:]"
+ .."image[6,1;2,1;"..u_skins.u_skins[name]..".png]"
else
formspec = formspec
diff --git a/update_from_db_hacky.py b/update_from_db_hacky.py
new file mode 100644
index 0000000..1ae3280
--- /dev/null
+++ b/update_from_db_hacky.py
@@ -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!")
+