From f8e316bdc494458e12471881b9b801df21505240 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Fri, 23 Dec 2022 12:56:57 +0100 Subject: [PATCH] Repeat the same level until success --- lambdaV.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lambdaV.py b/lambdaV.py index 9c9d57d..c66b11b 100644 --- a/lambdaV.py +++ b/lambdaV.py @@ -516,7 +516,11 @@ def setup_and_run_task(start_field, start_position, start_heading, text, allowed print("\n"+text) print("\nAllowed commands: "+", ".join(allowed_commands)) print("\nAvailable conditions: "+", ".join(allowed_conditions)) - print(evaluate_parser_result(parse_code(input("\nCode: "), allowed_commands, allowed_conditions))) + result = evaluate_parser_result(parse_code(input("\nCode: "), allowed_commands, allowed_conditions)) + print(result) + if result=="Success!": + return True + return False if __name__ == "__main__": import sys, os, json @@ -568,7 +572,8 @@ if __name__ == "__main__": else: print("Unknown start heading!") sys.exit(1) - setup_and_run_task(level_data["field"], level_data["start position"], cursor_start, level_data["text"], level_data["allowed commands"], level_data["allowed conditions"]) + while not setup_and_run_task(level_data["field"].copy(), level_data["start position"].copy(), cursor_start, level_data["text"], level_data["allowed commands"].copy(), level_data["allowed conditions"].copy()): + time.sleep(3) if single_file_mode: break