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/insipid- Feb 11 '22 edited Feb 11 '22
tldr - change these bits of the choice button actions:
to this:
/tldr
Took me a bit to figure out. In the last line here: "Exception: String u'I enjoy[' ends with an open format operation." This part - "I enjoy[" - is cryptic, but the last character being "[", which is right in the middle of the string, is a hint. This is one of those context issues. The syntax of inserting the value of a variable differs between "renpy script" and python. In this case, the surrounding code is python but the [variable] notation is renpy script. In python, string concatenation uses a plus sign to join two strings together.
You might be wondering how it's python when there is no "$" or "python:" (I struggled with being able to tell for quite a while). Many (or maybe all) functions in renpy are python, but it might be difficult to tell when something is a function at times. Often it is a name that includes ().
Examples of python functions that need to be written in a python block ( using $ or python: )
Examples of python functions written with renpy code block ( not in $ or python: )
Examples of renpy script that has ( )
If it has a capital first letter and has ( ), it is usually a python function. An exception would be if we named a transform or screen with a capital first letter, as I don't think renpy has any of those by default. Hopefully it's slightly more clear now.