-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuttonmaker.py
More file actions
57 lines (47 loc) · 1.52 KB
/
buttonmaker.py
File metadata and controls
57 lines (47 loc) · 1.52 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
import os
import sys
def is_int(s):
try:
int(s)
return True
except ValueError:
return False
os.chdir(os.path.dirname(__file__))
arg = ""
if len(sys.argv) > 1:
arg = sys.argv[1]
if arg == "":
raise input(
'No file provided! Please drag char.ini onto this script so it can rename buttons properly.')
droppedFile = open(arg, "r")
reverse = input(
'Rename numbered buttons back to their emotes? (y/n): ').lower() == 'y'
state = input('Input state (on or off): ').lower()
for line in droppedFile.readlines():
try:
words = line.rstrip().split(' ')
if words[0] in ('[SoundN]', '[SoundT]'):
break
num = words[0].split('=')[0]
if not is_int(num):
continue
emote = line.split('#')[2]
print(emote)
for button in os.listdir():
if reverse:
if button.lower() == f'button{num}_{state}.png':
os.rename(button, f'{emote.lower()}.png')
print(f'Renamed button {num} back to {emote}')
break
elif button.lower() == emote.lower() + '.png':
os.rename(button, 'button{}_{}.png'.format(num, state))
print('Made a new button for {}'.format(emote))
break
print('Currently on {}'.format(line))
except:
print("Excepted on line {}".format(line))
continue
input('Donezo')
# while F in os.listdir():
# os.rename(F, 'button{}_{}.png'.format(i, state))
# i+=1