Video:
Bitte melden Sie sich an, um dieses Medienelement zu sehen.
Code:
Code
- # Script by: Grzyb.ovh
- # The script automatically translates the drop from mob_drop_item.txt and special_item_group.txt files, utilizing the information in the locale_name.txt file
- import chardet
- import codecs
- def detect_encoding(filename):
- with open(filename, 'rb') as f:
- result = chardet.detect(f.read())
- return result['encoding']
- with codecs.open('item_names.txt', 'r', encoding='cp1250') as source_file:
- contents = source_file.read()
- with codecs.open('item_names_utf8.txt', 'w', encoding='utf-8') as target_file:
- target_file.write(contents)
- with open('item_names_utf8.txt', 'r', encoding='utf-8') as f:
- item_names = {}
- for line in f:
- if 'VNUM' in line or 'LOCALE_NAME' in line:
- continue
- vnum, name = line.strip().split('\t')
- item_names[vnum] = name
- drop_cpp_encoding = detect_encoding('drop.txt')
- with open('drop.txt', 'r', encoding=drop_cpp_encoding) as f:
- lines = f.readlines()
- new_lines = []
- for line in lines:
- if line.startswith('Group') or 'exp' in line:
- new_lines.append(line)
- else:
- parts = line.split('\t')
- if len(parts) > 2 and parts[2] in item_names:
- line = line.rstrip() + ' // ' + item_names[parts[2]] + '\n'
- new_lines.append(line)
- with open('drop2.txt', 'w', encoding='utf-8') as f:
- f.writelines(new_lines)
- # Script by: Grzyb.ovh