Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
init python:
my_string = "string"
lst = [my_string]
index_number = 0
screen testscreen:
# textbutton "[lst[index_number]]" # this gives me TypeError: list indices must be integers, not unicode
textbutton "[lst[0]]" # this works
How can I make number that is variable inside another square bracket work correctly with textbutton?
Last edited by Luxliev on Thu Aug 03, 2017 1:40 pm, edited 2 times in total.
Bracket interpolation (which is renpy-specific) just doesn't support it. You can use python's own interpolation, or use an intermediary variable as Remix suggested.