Skip to content

Instantly share code, notes, and snippets.

@MightyAlex200
Created December 11, 2019 15:05
Show Gist options
  • Save MightyAlex200/973018426ee126e2783b0f13ec07dca2 to your computer and use it in GitHub Desktop.
Save MightyAlex200/973018426ee126e2783b0f13ec07dca2 to your computer and use it in GitHub Desktop.
AIDungeon2 retry command
%%bash
# Retry command
echo """From a791a1e861744ad43ef7d1428738bdbead84491c Mon Sep 17 00:00:00 2001
From: MightyAlex200 <[email protected]>
Date: Wed, 11 Dec 2019 09:58:24 -0500
Subject: [PATCH] Retry command
---
play.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/play.py b/play.py
index 31cd2bd..7827ee6 100644
--- a/play.py
+++ b/play.py
@@ -207,6 +207,36 @@ def play_aidungeon_2():
else:
console_print(story_manager.story.story_start)
continue
+
+ elif action == 'retry':
+
+ if len(story_manager.story.actions) is 0:
+ console_print(\"There is nothing to retry.\")
+ continue
+
+ last_action = story_manager.story.actions.pop()
+ last_result = story_manager.story.results.pop()
+
+ try:
+ # Compatibility with timeout patch
+ act
+ except NameError:
+ act = story_manager.act
+
+ try:
+ try:
+ act(last_action)
+ console_print(last_action)
+ console_print(story_manager.story.results[-1])
+ except FunctionTimedOut:
+ story_manager.story.actions.append(last_action)
+ story_manager.story.results.append(last_result)
+ notify_hanged()
+ console_print(\"Your story progress has not been altered.\")
+ except NameError:
+ pass
+
+ continue
else:
if action == \"\":
--
2.24.0""" > fix.patch
# email and username required
git config user.email "[email protected]"
git config user.name "Anonymous"
git am --3way fix.patch && echo Patch Applied!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment