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.
While running game code:
File "game/script.rpy", line 25, in script
call screen body
File "renpy/common/000statements.rpy", line 609, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
Exception: In DynamicImage 'images/[items[[i]]].png': TypeError('list indices must be integers or slices, not str')
It works if do this instead: hover "images/[items[0]].png". But that would result in a lot of probably unnecessarally repetitive work. How to generalize the numbers?
for i in range(len(container)): container is an antipattern. If you do that, it is almost certainly wrong. Iterate on elements instead. You can have python statements inside your loop to prebuild paths, extract data from containers, etc. and not rely on interpolation and such.
for item in items:
$ imagepath = "images/" + item
imagebutton:
action Jump('test') # your condition is always true anyway
idle imagepath # no need to hover, since it is the same as idle
insensitive "inventory insensitive.png"
# do not use hovered/unhovered pair for something better done with tooltip.
If you do need index for something, you can use enumerate and tuple unpacking: