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.
This is a simplified version of the code I'm using, but hopefully everything important is here. When I try to run the full code, I get "TypeError: string indices must be integers", referring to the line indicated here. I think it's because I'm misunderstanding "for m in mails". Any ideas?
screen mailbox():
modal True
add "gui/nvl.png"
style_prefix "mailbox"
button:
area (10,70,260,50)
text "Main Folder"
action Show("mailbox3a", mails="mainfolder")
screen mailbox3a(mails):
tag mailbox3
style_prefix "mailbox3"
frame:
area(10,150,630,300)
vbox:
for m in mails:
button: ### This is the line the error refers to ###
hbox:
text m["sender"]
text m["subject"]
action Show("email_display", folder="Main Folder", sender=m["sender"], subject=m["subject"], email=m["email"])
label start:
$ mainfolder = [
{"sender":"Eileen",
"subject":"Maily Mail",
"email":"Bla Bla Bla",},
{"sender":"Lucy",
"subject":"Testing",
"email":"Bleep Bloop",}
]
show screen mailbox
1) I know I've told you this before, and I feel like it is all I say, but define your variables using default. So that mainfolder variable you are defining inside lable start should be defined outside of the label using default. And ANY variable you are using should be defined using default outside of a label. So that should be fixed.
2) In your mailbox screen you pass in a string called "mainfolder", you don't pass in the mainfolder object. So take the quotation marks out. But first make sure you are defining your variable using default.
Edit: Remix Ninja'd me. But didn't mention you still need to fix your variable declaration.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Thanks both of you for the help; I didn't know which string was causing the issue
and yes trooper, I went back through my entire code to define all the variables with default. It was causing me some problems before but I don't even remember why at this point. You may need to beat "define variables outside labels with default" into me again one day, but I'll get it eventually.