I'm trying to do this... could use some guidance...

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.
Post Reply
Message
Author
Boch
Newbie
Posts: 23
Joined: Fri Oct 13, 2006 4:40 am
Contact:

I'm trying to do this... could use some guidance...

#1 Post by Boch » Tue Oct 17, 2006 7:45 am

Hi, everyone! *waves*

I've got a question about Ren'Py (duh) and I hope someone out there in this big world has an answer.

Q: Is it possible to use If-Else statements in menu blocks?

I've tried looking through the forums and the tutorials available, but I can't seem to find what I'm looking for. The only example I can find is when you need to check whether to enable a menu item choice or not. The example was something like this:

Code: Select all

$ menu_was_used = []
menu this_is_a_menu:
     set menu_was_used_before
     "An option":
               "After this, a new option will be available"
               jump this_is_a_menu
     "This wasn't here before" if menu_was_used_before:
               "Blah blah blah"
               jump next_part
label next_part:
Actually, what I'm trying to accomplish is very simple.
Let's say I have an option called "Kill the smelly rat"

The first time you select this option, it will print out:
"You kicked the rat between the legs, ending its mortal life."

The second and subsequent times you select this option, it will print out:
"It's dead enough as it is."

If I use set, the "Kill the smelly rat" option will disappear after selecting it for the first time. I want the option to stay, but print a different message instead.
Just one more try...

User avatar
PyTom
Ren'Py Creator
Posts: 15378
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: I'm trying to do this... could use some guidance...

#2 Post by PyTom » Tue Oct 17, 2006 7:57 am

Boch wrote:If I use set, the "Kill the smelly rat" option will disappear after selecting it for the first time. I want the option to stay, but print a different message instead.
I'm not sure rat-killing is one of the traditional topics for visual novels... but whatever, I just make the paintbrushes.

You want to have two entries in the menu, both with if statements. Example:

Code: Select all

$ fed_rat = False

menu rat_feeding:
    "Feed the smelly rat." if not fed_rat:
         "Sure, the rat is vermin, but he's my kind of vermin."
         "I give him a big block of cheese."
         $ fed_rat = True
         jump rat_feeding
    "Feed the smelly rat." if fed_rat:
         "I just fed him."
         "He looks quite content."
         jump rat_feeding
Alternatively, you can factor the if statements inside the menu choice.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Boch
Newbie
Posts: 23
Joined: Fri Oct 13, 2006 4:40 am
Contact:

Re: I'm trying to do this... could use some guidance...

#3 Post by Boch » Tue Oct 17, 2006 8:35 am

Thanks for replying, Tom. This really helps.
PyTom wrote:I'm not sure rat-killing is one of the traditional topics for visual novels... but whatever, I just make the paintbrushes.
Oh, don't worry, the rat was just an example. I'd have to be crazy to do a VN about a rat.
Hmm, now there's an idea...

I'm interested in the alternative of having ifs inside the menu choice that you mentioned. Could you show me a syntax example?
Also, can the ifs do a check against a variable instead of just a boolean for the line where the menu choice is?
Just one more try...

User avatar
PyTom
Ren'Py Creator
Posts: 15378
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: I'm trying to do this... could use some guidance...

#4 Post by PyTom » Tue Oct 17, 2006 8:44 am

Boch wrote:I'm interested in the alternative of having ifs inside the menu choice that you mentioned. Could you show me a syntax example?
Also, can the ifs do a check against a variable instead of just a boolean for the line where the menu choice is?
Yes on both accounts.

Code: Select all

$ times_through = 0

menu:
    "A wild and crazy choice.":
        $ times_through += 1
        if times_through == 1:
            "This is my first time taking the choice."
        else:
            "It feels like I've been here before."
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Boch
Newbie
Posts: 23
Joined: Fri Oct 13, 2006 4:40 am
Contact:

#5 Post by Boch » Tue Oct 17, 2006 8:54 am

Thanks again! :)
Just one more try...

Guest

#6 Post by Guest » Mon Oct 23, 2006 5:42 am

Here's another simple question, how do I change the default color for a menu's text? Currently it's using light blue and yellow.

User avatar
PyTom
Ren'Py Creator
Posts: 15378
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#7 Post by PyTom » Mon Oct 23, 2006 8:49 am

Code: Select all

init:
    $ style.menu_choice.idle_color = "#ff00ff"
    $ style.menu_choice.hover_color = "#ff0000"
This changes the idle color to purple, and the hover color to red. Change the colors to fit.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Bing [Bot]