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.
to a similar screen that will add and remove list items based on which items you have in your inventory. The inventory will be determined by a list (eg "example_list = [0, 3, 2]") that will have items added and subtracted to it using list append. The textbuttons will lead you to screens where more information on the items can be viewed. However, I only want textbuttons to show up if you have the item. How would I go about this?
Would this work?
screen items_screen:
frame:
has vbox
if "one" in "listname":
textbutton "one"
if "two" in "listname":
textbutton "two"
if "three" in "listname":
textbutton "three"
textbutton "Back" action Return()
Most programming languages will have a loop structure specifically to allow you to loop through all the items in your list. They're usually called a for loop: http://treyhunner.com/2016/04/how-to-lo ... in-python/ (scroll down to "for-in: the usual way")
screen items_screen:
frame:
has vbox
for i in listname:
textbutton i action ???
textbutton "Back" action Return()
Basically in a for i in list loop in python, it'll go through the loop as many times as there are items, and each iteration of the loop, i contains whatever value your current list item is. So you can directly reference i as the item (i.e. textbutton i in this case.) What you need to be more conscious of in this situation is what the screen action is going to be: It needs to incorporate i in some form, whether it's a Call() that uses i, or another screen action that takes i and make the action contextual to what the item is.
update: I forget if that error was even with this or something else but now I have parenthesis around it and it is working fine. So... parenthesis are a good thing i guess
Last edited by TheChatotMaestro on Mon May 28, 2018 5:03 pm, edited 1 time in total.