[SOLVED] How can I act upon a player's Text Input without needing an 'Enter' press?
Posted: Sun Apr 03, 2022 11:57 am
Hi, I need help trying to change the default way text input behaves.
I am creating a typing game where words appear on the screen and the player needs to type them out as fast as they can (similar to games like 'The Typing of the Dead'). I have all the groundwork set up. In fact, the project is very playable at this stage. A word appears together with a bar timer, and using renpy.input the player can type freely. My issue is that an Enter press is required for the text input to be processed. For this game, that is an extra unnecessary input I would like to get rid of.
I would like the text input to be processed immediately once it matches the word presented to the player, without the need for an Enter press or Confirm button.
Here is a simplified version of how I currently have things set up:
In addition to this, a screen with a timer is shown for each word, where some variables are affected if it runs out. The timer is refreshed each time a correct input is entered. Probably not super relevant to my issue but I thought I'd mention it anyway.
People have recommended that I subclass InputValue, and use VariableInputValue in some way. Unfortunately, while I have worked with Ren'Py for a few years, there are some aspects of coding and syntax I know almost nothing about. I'm not sure how to create a useful subclass, or exactly how to use it in conjunction with the rest of the script. Similarly, I don't know how exactly I can use VariableInputValue to accomplish my goal. Bottom line is; I may need a thorough explanation of what needs to be done so I can understand the what, how and why.
I've asked around in the Discord, and while I super appreciate the help, I find myself needing a proper thread to figure out all the little details that are involved in this issue and don't want to spam
I am creating a typing game where words appear on the screen and the player needs to type them out as fast as they can (similar to games like 'The Typing of the Dead'). I have all the groundwork set up. In fact, the project is very playable at this stage. A word appears together with a bar timer, and using renpy.input the player can type freely. My issue is that an Enter press is required for the text input to be processed. For this game, that is an extra unnecessary input I would like to get rid of.
I would like the text input to be processed immediately once it matches the word presented to the player, without the need for an Enter press or Confirm button.
Here is a simplified version of how I currently have things set up:
Code: Select all
label generate_word:
$ lvl1_word = renpy.random.choice(lvl1) # active_word is what the player needs to type at any given time. These are selected randomly from a list
$ active_word = lvl1_word
jump typing
label typing:
$ playertype = renpy.input("[active_word]")
if case_sensitive == False: # a 'hardcore mode' can be enabled which enables case_sensitivity and accurate punctuation (latter not included for simplicity)
$ active_word = active_word.lower()
$ playertype = playertype.lower()
jump resolve
label resolve:
if playertype == active_word: # sometimes there will be multiple words on screen at once, other times the player can type 'powerup' words using different variables than 'active_word' (not included for simplicity).
$ points += 20 # basically, whatever the solution is to my problem, it also needs to accommodate multiple different 'correct' words.
$ combo += 1
$ enemy_hp -= 10
if enemy_hp <= 0:
jump enemy_dead
else:
jump generate_word
People have recommended that I subclass InputValue, and use VariableInputValue in some way. Unfortunately, while I have worked with Ren'Py for a few years, there are some aspects of coding and syntax I know almost nothing about. I'm not sure how to create a useful subclass, or exactly how to use it in conjunction with the rest of the script. Similarly, I don't know how exactly I can use VariableInputValue to accomplish my goal. Bottom line is; I may need a thorough explanation of what needs to be done so I can understand the what, how and why.
I've asked around in the Discord, and while I super appreciate the help, I find myself needing a proper thread to figure out all the little details that are involved in this issue and don't want to spam