Bitte melden Sie sich an, um dieses Medienelement zu sehen.
Code
- # Script by Grzyb.ovh
- def convert_to_quest(input_text, quest_name, state_name, npc_id, chat_option):
- quest_code = f"quest {quest_name} begin\n\tstate {state_name} begin\n\t\twhen {npc_id}.chat.\"{chat_option}\" begin\n"
- lines = input_text.split('\n')
- indentation_level = 0
- for line in lines:
- stripped_line = line.strip()
- if stripped_line.startswith("end"):
- indentation_level -= 1
- stripped_line = stripped_line.replace(" (", "(").replace(" )", ")")
- stripped_line = stripped_line.replace(" . ", ".")
- stripped_line = stripped_line.replace(' "', '"')
- indent = '\t' * (3 + indentation_level)
- quest_code += f"{indent}{stripped_line}\n"
- if stripped_line.startswith(("if", "while", "for")) and "end" not in stripped_line:
- indentation_level += 1
- quest_code += "\t\tend\n\tend\nend"
- return quest_code
- def process_script_file(script_file_name, quest_name, state_name, npc_id, chat_option):
- with open(script_file_name, 'r', encoding='latin1') as f:
- input_text = f.read()
- quest_code = convert_to_quest(input_text, quest_name, state_name, npc_id, chat_option)
- quest_file_name = script_file_name.replace('.script', '.quest')
- with open(quest_file_name, 'w', encoding='latin1') as f:
- f.write(quest_code)
- process_script_file('marriage_manage.start.0.script', 'weeding', 'start', 20358, 'Oldwoman')