-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModGenerator.py
More file actions
147 lines (128 loc) · 6.39 KB
/
ModGenerator.py
File metadata and controls
147 lines (128 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# #!/usr/bin/python3.8
import os
import sys
from shutil import copyfile
from termcolor import colored
print(colored('''
███ ███ ██████ ██████ ██████ ███████ ███ ██ ███████ ██████ █████ ████████ ██████ ██████
████ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ████ ██ ██ ██ ██ ██ ██ ███ █████ ██ ██ ██ █████ ██████ ███████ ██ ██ ██ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██████ ██████ ██████ ███████ ██ ████ ███████ ██ ██ ██ ██ ██ ██████ ██ ██
сделано в Terraria-SNG с <3
''','magenta'))
def coderun():
z = 0
x = 0
c = 0
v = 0
erz = None
erx = None
erc = None
erv = None
cred()
try:
Mn = raw_input("Напишите название мода (Без пробелов и специальных символов!): ")
Mn = Mn.translate(None, ' \\/":.,><`~!@#$%^&?;*+=')
if not Mn:
raise ValueError
else:
z = 1
except ValueError:
erz = "Название мода"
try:
Md = raw_input("Напишите имя мода: ")
if not Md:
raise ValueError
else:
x = 1
except ValueError:
erx = "Имя мода"
try:
It = raw_input("Название первого предмета (Без пробелов и специальных символов!): ")
It = It.translate(None, ' \\/":.,><`~!@#$%^&?;*+=')
if not It:
raise ValueError
else:
c = 1
except ValueError:
erc = "Название первого предмета+"
try:
MA = raw_input("Напишите имя автора: ")
if not MA:
raise ValueError
else:
v = 1
except ValueError:
erv = "Ваше имя"
b = z + x + c + v
if b == 4:
try:
os.makedirs(os.path.join("Вызод", Mn, "Предметы"))
except OSError:
print "Dir exists - skipping."
copyfile("Templates/Items/itemname.png", os.path.join("Output", Mn, "Items", It + ".png"))
copyfile("Templates/modname.csproj.user", os.path.join("Output", Mn, Mn + ".csproj.user"))
bldr = open(os.path.join("Шаблоны", "build.txt")).read()
bldr = bldr.replace('{username}', MA).replace('{displayname}', Md)
build = open(os.path.join("Выход", Mn, "build.txt"), "w")
build.write(bldr)
dscr = open(os.path.join("Шаблоны", "description.txt")).read()
dscr = dscr.replace('{displayname}', Md)
desc = open(os.path.join("Выход", Mn, "description.txt"), "w")
desc.write(dscr)
Itcr = open(os.path.join("Шаблоны", "Предметы", "itemname.cs")).read()
Itcr = Itcr.replace("{modname}", Mn).replace("{itemname}", It)
Itcs = open(os.path.join("Выход", Mn, "Предметы", It + ".cs"), "w")
Itcs.write(Itcr)
mncr = open(os.path.join("Шаблоны", "modname.cs")).read()
mncr = mncr.replace('{modname}', Mn)
mncs = open(os.path.join("Выход", Mn, Mn + ".cs"), "w")
mncs.write(mncr)
mnpr = open(os.path.join("Шаблоны", "modname.csproj")).read()
mnpr = mnpr.replace('{modname}', Mn)
mnpj = open(os.path.join("Выход", Mn, Mn + ".csproj"), "w")
mnpj.write(mnpr)
else:
cred()
print "ОШИБКА!!! |Следующие поля пусты.\n-----------------------------------"
if z != 1:
print erz
if x != 1:
print erx
if c != 1:
print erc
if v != 1:
print erv
print ""
def cred():
clear = lambda: os.system('cls' if os.name=='nt' else 'clear')
clear()
print "TModloader Mod Generator\n\nСоздан в Terra-SNG.\n."
print "--------------------------------------------------------------------------\n"
def FC():
BaseFileCheck = ['build.txt', 'description.txt', 'modname.cs', 'modname.csproj', 'modname.csproj.user']
ItemsFileCheck = ['itemname.cs', 'itemname.png']
cred()
try:
for x in BaseFileCheck:
if not os.path.isfile(os.path.join("Шаблоны", x)):
raise IOError
for x in ItemsFileCheck:
if not os.path.isfile(os.path.join("Шаблоны", "Предметы", x)):
raise IOError
except IOError:
print "В папке templates отсутствует один или несколько файлов. Генератор не может продолжать работу.\n"
raw_input("Нажмите 'enter' чтоб закрыть окно.")
sys.exit(0)
while True:
FC()
coderun()
while True:
lsg = raw_input("Хотели бы вы создать еще один скелет? Введите "y", в противном случае "n", чтобы закрыть.. ")
if lsg.lower() == 'y':
break
elif lsg.lower() == 'n':
sys.exit(0)
else:
print "Недопустимая команда. Чтобы создать другой скелет, введите "y", в противном случае "n", чтобы закрыть.\n"