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.
Fairly experienced coder, Renpy has been somewhat confusing so far but am starting to get a pretty good handle on how it interacts with actual Python code (which has made me far more comfortable). I encountered my first error tonight that I can't seem to figure out.
I am building out an inventory screen. The InventoryManager is a defined class with an inventory dictionary as a property and some methods for adding InventoryItems to and taking them away from the dictionary. The inventory screen contains a grid, and I iterate through the inventory dictionary keys (which are the item names) to obtain all of the items and populate the grid with the associated images (each InventoryItem has a file string field). I then populate the empty grid spaces with empty strings (so as not to get the unfilled grid error):
grid 5 2 xpos 137 ypos 335:
$ total = len(inventory.inventory.keys())
for key in inventory.inventory.keys():
$ img = str(inventory.inventory[key].image)
imagebutton auto "[img]_%s.png" action Null
$ rem = 10 - total
for i in range(0, rem):
text "{size=+10}{font=architect.ttf}{/font}{/size}"
However, when I run the program, I get an "Imagebutton does not have a idle image. (auto=u"[img]_%s")" error. It is apparently interpreting the "[img]" bracket interpolation as simply being the name of the file. I have tested the interpolation with a standard image, and it works fine. I'm fairly sure that the issue stems from the combination of the renpy bracket interpolation and the string substitution (%s), but I'm not sure how to get around it. Any help would be appreciated.