也许还能简化,但能用就行- import os,uuid
- def pack(a,b):
- global skins,lang
- skins+='{"localization_name":"'+a[0:-4]+'","geometry":"'+b+'","texture":"'+a+'","type":"free"},\n'
- lang+="skin."+name+"."+a[:-4]+"=\n"
- #文件需放在图片所在路径,并确保只有图片
- files=os.listdir(".") #扫描文件
- files.remove("皮肤打包工具.py") #去掉代码文件本身,因此给代码文件改名同时要改掉这条语句
- print(files,"\n共%d个皮肤"%len(files))
- name=input("输入皮肤包名称:")
- #粗壮即4像素手臂,纤细即3像素手臂
- format=input("输入体型(c为全粗壮,s为全纤细;0和1分别代表粗壮和纤细,需按照顺序逐个输入)")#例如3个皮肤文件输入010,分别按照顺序将皮肤设置成粗壮、纤细、粗壮
- v1,v2,v3=input("输入版本号(格式为a,b,c)").split(",")
- skins=""
- lang=""
- if format=="c":
- for skin in files:
- pack(skin,"geometry.humanoid.custom")
- elif format=="s":
- for skin in files:
- pack(skin,"geometry.humanoid.customSlim")
- else:
- for i in range(len(files)):
- if format[i]=="0":
- pack(files[i],"geometry.humanoid.custom")
- elif format[i]=="1":
- pack(files[i],"geometry.humanoid.customSlim")
- os.mkdir("texts")
- with open("skins.json","w+") as skinf:
- with open("texts/zh_CN.lang","w") as langf:
- skinf.write('{"geometry":"skinpacks/skins.json","skins":[\n'+skins[:-2]+'\n],"serialize_name":"'+name+'","localization_name":"'+name+'"}')
- langf.write(lang+"skinpack."+name+"=")
- ver=str([int(v1),int(v2),int(v3)])
- with open("manifest.json","w") as manifest:
- manifest.write('{"format_version":1,\n"header":{"name":"'+name+'","uuid":"'+str(uuid.uuid4())+'","version":'+ver+'},\n"modules":[{"type":"skin_pack","uuid":"'+str(uuid.uuid4())+'","version":'+ver+'}]}')
- print("完成!语言文件请自行添加内容或删除")
复制代码 |