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.
I have a screen that displays an email, and I want to have a "Reply" button which brings up a choice menu over the top of the screen. Any idea how to do that?
While running game code:
File "game/day0scenes.rpy", line 173, in script
call screen email_display("Laplace Mail", "The Observer", "Laplace Mail", "Good morning.\nHere is today's NEWS.\n\n1. At around 16:00, a man will {color=#ffca1e}be killed{/color} in Shibuya-ku Aoyama apartment. The wounds on the corpse are consistent with an attack by a large carnivorous beast.\n\n2. A large {color=#ffca1e}explosion{/color} will occur in Minato-ku Aoyama at 19:00. The cause is unknown.\n\n3. At 21:00, a {color=#ffca1e}blackout{/color} will affect the entire Tokyo metropolitan area.\n\nHave a nice day.", True, ["Yessir":"That doesn't really answer my question", "Nah":"I'll go ask someone else"])
File "renpy/common/000statements.rpy", line 466, in execute_call_screen
args, kwargs = a.evaluate()
SyntaxError: invalid syntax (game/day0scenes.rpy, line 173)
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/day0scenes.rpy", line 173, in script
call screen email_display("Laplace Mail", "The Observer", "Laplace Mail", "Good morning.\nHere is today's NEWS.\n\n1. At around 16:00, a man will {color=#ffca1e}be killed{/color} in Shibuya-ku Aoyama apartment. The wounds on the corpse are consistent with an attack by a large carnivorous beast.\n\n2. A large {color=#ffca1e}explosion{/color} will occur in Minato-ku Aoyama at 19:00. The cause is unknown.\n\n3. At 21:00, a {color=#ffca1e}blackout{/color} will affect the entire Tokyo metropolitan area.\n\nHave a nice day.", True, ["Yessir":"That doesn't really answer my question", "Nah":"I'll go ask someone else"])
File "C:\Users\-\Desktop\renpy-6.99.12.4-sdk\renpy\ast.py", line 1706, in execute
self.call("execute")
File "C:\Users\-\Desktop\renpy-6.99.12.4-sdk\renpy\ast.py", line 1724, in call
return renpy.statements.call(method, parsed, *args, **kwargs)
File "C:\Users\-\Desktop\renpy-6.99.12.4-sdk\renpy\statements.py", line 145, in call
return method(parsed, *args, **kwargs)
File "renpy/common/000statements.rpy", line 466, in execute_call_screen
args, kwargs = a.evaluate()
File "C:\Users\-\Desktop\renpy-6.99.12.4-sdk\renpy\ast.py", line 184, in evaluate
args.append(renpy.python.py_eval(v, locals=scope))
File "C:\Users\-\Desktop\renpy-6.99.12.4-sdk\renpy\python.py", line 1748, in py_eval
code = py_compile(code, 'eval')
File "C:\Users\-\Desktop\renpy-6.99.12.4-sdk\renpy\python.py", line 584, in py_compile
raise e
SyntaxError: invalid syntax (game/day0scenes.rpy, line 173)
Why do you want to use choice screen in the first place? You can create your own screen that would have similar appearence but will do exactly the things you need it to do... And you could pass to it the values you like...
Also it's not a good idea to make your screens show lots of stuff 'cause you might face the issues with saving the game state. It might be better to show all the complex stuff in labels... https://www.renpy.org/doc/html/save_load_rollback.html
As for ["Yessir":"That doesn't really answer my question", "Nah":"I'll go ask someone else"] part - it either should be a dict (figure bracets {}) or a list (then elements must be separated with commas)
I second what Alex said; it's better to make your custom screen than try to abuse the choice screen.
Also, I think you are not understanding the choice screen as well as you believe (I don't understand it 100% myself). items there is a list of objects with the fields .caption and .action, not a dictionary.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
First off, yes Alex I forgot to put the right brackets for the dictionary. Once I fixed that, it returned with another error affirming what you said, MilkyMalk. I can't just pass a dictionary to the choice screen, it has to be a list of tuples. The renpy.display_menu works, because it uses the look of the choice screen (I wanted it to look identical to the choice screen, which is why I wanted to try and call the choice screen with arguments of some kind). When I tried Function(renpy.display_menu, "stuff") it gave me a "you can't start an interaction within an interaction" error so I made it call a label and that worked.
I want to make only a few certain emails "replyable" which is hard to do with the dictionary data system I have right now. Probably tomorrow morning I'll try and redefine everything using a class and that should fix it.
Thanks for the help!
init -1 python:
class Email(object):
def __init__(self, sender, subject, body):
self.sender = sender
self.subject = subject
self.body = body
class ReplyableEmail(Email):
def __init__(self):
self.replyable = True
default email4 = Email("sender4", "subject4", "body4")
default email5 = ReplyableEmail("sender5", "subject5", "body5")
default replyable = False
screen email_display(folder, email):
modal True
add "gui/nvl.png"
style_prefix "email_display"
use email_display2(email)
use email_display3(folder)
if not at_checkpoint:
textbutton "Return" action Return() at returnbuttonmail
else:
textbutton "Return" action Hide("email_display") at returnbuttonmail
if email.replyable:
textbutton "Reply" action Function(renpy.call, "mailreply")
### And there's more code to this screen but I think it's irrelevant here.
So I reworked everything into a class (Really new to it so I really don't understand it yet) like this, and I've gotten everything to work the way it did with dictionaries, but I'm not sure how to use a derived class to create the "replyable" condition. I get this error:
Am I just... Is this not how you use derived classes? Am I just doing it wrong or should I not be using a derived class at all? What are they used for, generally?
class Pet(object):
def __init__(self, name, species):
self.name = name
self.species = species
class Dog(Pet):
def __init__(self, name, chases_cars):
Pet.__init__(self, name, 'dog')
self.chases_cars = chases_cars
In short, you have to call the specific __init__ method of the parent class with the arguments and for that you need the child class to accept them in the first place.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
class Pet(object):
def __init__(self, name, species):
self.name = name
self.species = species
class Dog(Pet):
def __init__(self, name, chases_cars):
Pet.__init__(self, name, 'dog')
self.chases_cars = chases_cars
In short, you have to call the specific __init__ method of the parent class with the arguments and for that you need the child class to accept them in the first place.
I had a very similar problem, so that's how it's done, I somehow knew I had to call the parent's init method first, otherwise we would be just overwriting the method(I think), but I was trying to call it with super() to no avail, this does seem more correct, thanks, Milkymalk.
The silent voice within one's heart whispers the most profound wisdom.