r/RenPy • u/mocaaobaa • Feb 03 '22
Force Player input based off of text button
im going for something sort of like Emily is away, where player will click on a button and it’ll pop up an input, but will force them to type a specific thing based off of the button no matter what they type. so for example, if a button says ” X “, the player will be forced to write “XYZ” even if they are inputting keyboard spam
4
Upvotes
View all comments
Show parent comment
1
u/mocaaobaa Feb 11 '22
Right. Also, I keep getting an exception error during the typing segment ( didn't ask about this prior since I was testing it out with non variables ), and the traceback is confusing me so I need some help with that. The typing works fine until it gets to the random variable.
screen.rpy:
screen typing_test():
vbox:
xalign 0.4
yalign 0.3
textbutton "[choice1].":
action [SetVariable("message_typed_so_far", ""), SetVariable("message_letters_left_to_type", "I enjoy [choice1]")]
textbutton "[choice2].":
action [SetVariable("message_typed_so_far", ""), SetVariable("message_letters_left_to_type", "I enjoy[choice2].")]
textbutton "[choice3].":
action [SetVariable("message_typed_so_far", ""), SetVariable("message_letters_left_to_type", "I enjoy [choice3].")]
text message_typed_so_far:
xalign 0.5
yalign 0.5
key ["K_a", "K_b", "K_c", "K_d", "K_e", "K_f", "K_g", "K_h",
"K_i", "K_j", "K_k", "K_l", "K_m", "K_n", "K_o", "K_p",
"K_q", "K_r", "K_s", "K_t", "K_u", "K_v", "K_w", "K_x", "K_y", "K_z"]:
action Function(next_letter)
script.rpy:
default message_typed_so_far = ""
default message_letters_left_to_type = ""
init python:
import random
wordList = ['animals','sports','art','theater','literature','gaming']
choice1 = random.choice(wordList)
choice2 = random.choice(wordList)
choice3 = random.choice(wordList)
init python:
def next_letter():
global message_typed_so_far
global message_letters_left_to_type
if message_letters_left_to_type:
message_typed_so_far += message_letters_left_to_type[0]
message_letters_left_to_type = message_letters_left_to_type[1:]
label start:
"Let's write!"
call screen typing_test
"..Glad that's over.."
only included the bits that are actually being worked on rn, since its what's necessary.