Commits

Anonymous committed df814d6

TextRPGs können mit 'avatarsay --fullscreen --execute python tutorial_de.py' gespielt werden! -> http://akfoerster.de/akfavatar/akfavatar.de.html

  • Participants
  • Parent commits 066346b

Comments (0)

Files changed (2)

File branching_story.py

 
 'the angry boar': """
 As you enter a darker region of the woods, you hear the rustling of leaves behind you. 
+
 Minutes later, you still don't quite know, how you escaped, 
 but the boar doesn't follow you anymore. 
 """, 

File rpg_lib/anyrpg.py

 class UserInteraction(object): 
     """Basic user interaction: Showing and asking things."""
     def __init__(self, *args, **kwds): 
-	self.line_length = 80 #: The maximum length of story lines. 
+	self.line_length = 60 #: The maximum length of story lines. 
 	self.line_wait = 0.4
 	self.char_wait = 0.05
         super(UserInteraction, self).__init__(*args, **kwds)
 	@param line_length: Maximum length of a line. 
 	
 	"""
-	# Split the text by words to output at most 80 chars per line. 
+	# Split the text by words to output at most self.line_length chars per line. 
 	if line_length is None: 
 	    line_length = self.line_length
 	text_to_print = ""
 	for j in text.split(): 
 	    if len(line_beginning) + len(text_to_print) + len(j) > line_length: 
 		self.diag(line_beginning + text_to_print, localize=localize, autoscroll=autoscroll, *args, **kwds) 
-		# If j > 80 -> split j and use only the remaining rest as default, printing all else directly. 
-		if len(line_beginning) + len(j) > 80: 
-		    while j[80 - len(line_beginning):]: 
-			self.diag(line_beginning + j[:80 - len(line_beginning)], localize=localize, autoscroll=autoscroll, *args, **kwds)
-			j = j[80 - len(line_beginning):]
+		# If j > self.line_length -> split j and use only the remaining rest as default, printing all else directly. 
+		if len(line_beginning) + len(j) > self.line_length: 
+		    while j[self.line_length - len(line_beginning):]: 
+			self.diag(line_beginning + j[:self.line_length - len(line_beginning)], localize=localize, autoscroll=autoscroll, *args, **kwds)
+			j = j[self.line_length - len(line_beginning):]
 		text_to_print = j
 	    else: 
 		# if we already have text_to_print, add j with a space. 
 		for i in range(len(_("...press enter to read on..."))): 
 		    sys.stdout.write(" ")
                 sys.stdout.flush()
-		sleep(line_wait)
+		#sleep(line_wait)
             # First sleep 1/10th second. This ensures that the text gets shown before sleeping.
             sleep(char_wait)
 	    # If we have text, wait one 10th of a second per char.