Code: Select all
label codingRound(end_label="codingGameWon", codeDisplay=None, default=""):
python:
if codeDisplay is None: #if display is empty (which it is by default)
codeDisplay = codingLines.pop() #variable is assigned a random subject
typed = renpy.input(codeDisplay) #variable is user input
if typed != codeDisplay: #If user input does not match the subject
call codingRound (end_label, codeDisplay=codeDisplay) from _call_codingRound_1 #restart round with the same subject
else:
$ codeRoundsCorrect += 1 #increment the number of rounds
if codeRoundsCorrect >= codingRoundNumber: #if successfull rounds meets max rounds
$ renpy.call(end_label) #end the game
else:
call codingRound (end_label) from _call_codingRound_2 #start another round
return#1 the prompt is given and the user starts typing
Prompt: The sky is blue
Input: The s
#2 The user misspells, changing the input color
Prompt: The sky is blue
Input: The sku is bl
#3 User deletes past the error, reverting the color back to normal
Prompt: The sky is blue
Input: The sk
It's a small thing, and not strictly necessary if it would take a lot of effort to make it work. Mainly just curious if there might be a relatively simple method to accomplish this. I'm not really a programmer and i've been doing a lot of reverse engineering and backsolving from other people's code examples to get this far. My best guess would be some kind of loop that constantly compares the user input with the codeDisplay and triggers the color change accordingly, but i'm not sure how to go about implementing that.