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.
Let's say you want to ask the player a lot of questions. Each of the menu choices will be colored differently depending on whether or not the player has agreed for help.
menu:
"Do you want my help?"
"Yes":
$help=True
"No":
$help=False
menu:
"How do you feel about this issue?"
"Good.": #this word will be in GREEN text if help==True, otherwise default black
pass
"Bad.": #this word will be in RED text if help==True, otherwise default black
pass
"So so.": #this word will be in YELLOW text if help==True, otherwise default black
pass
menu:
"What's your favorite animal?"
"Lion.": #this word will be in YELLOW text if help==True, otherwise default black
pass
"Cat.": #this word will be in GREEN text if help==True, otherwise default black
pass
"Moose.": #this word will be in RED text if help==True, otherwise default black
pass
#and so forth for several questions using Green, Red, Yellow options
What can be done to make this work? I can't find a way to make the inline style optional.
I also thought I might be able to define a style and change its color depending on the value of "help", but it doesn't seem like you can make styles optional in that way.
Would registering a style preference work better in this case? But if so, what would you be registering exactly since it's the default text?
Coming Out On Top - An Adult Gay Dating Sim website
default mhelp = False
screen choice(items):
style_prefix "choice"
vbox:
for i in items:
if "(g)" in i.caption:
textbutton i.caption.replace("(g)", "") action i.action:
if mhelp:
text_color '#0f0'
elif "(r)" in i.caption:
textbutton i.caption.replace("(r)", "") action i.action:
if mhelp:
text_color '#f00'
elif "(y)" in i.caption:
textbutton i.caption.replace("(y)", "") action i.action:
if mhelp:
text_color '#fe0'
else:
textbutton i.caption action i.action #<< default
label start:
menu:
"Do you want my help?"
"Yes":
$ mhelp=True
"No":
$ mhelp=False
menu:
"How do you feel about this issue?"
"Good.(g)": #this word will be in GREEN text if help==True, otherwise default black
pass
"Bad.(r)": #this word will be in RED text if help==True, otherwise default black
pass
"So so.(y)": #this word will be in YELLOW text if help==True, otherwise default black
pass
menu:
"What's your favorite animal?"
"Lion.(y)": #this word will be in YELLOW text if help==True, otherwise default black
pass
"Cat.(g)": #this word will be in GREEN text if help==True, otherwise default black
pass
"Moose(r).": #this word will be in RED text if help==True, otherwise default black
pass
return
which presumable passes the parameters through to the item in the choice.
I've not had time to try this new feature yet, though believe it also allows passing arbitrary parameters on the menu: line which get passed to the screen
Thanks very much, IrinaLazareva! I'm not sure if I'll be able to use that since I already have multiple menus and am not sure how I'd integrate this into each one of them. But that's an extremely useful code to know for the future.
@Remix, thanks for the heads up. That looks like a great new feature.
Coming Out On Top - An Adult Gay Dating Sim website