Double-Menus.

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.
Message
Author
Jadeica

Double-Menus.

#1 Post by Jadeica »

I'm having a spot of trouble whilst working on my game.

My Menu Just won't work. Its all perfect until it gets to the menu. It'd be great if someone could help me out with this?
init:
image bg office = "edgysoffice.jpg"
image bg uni = "uni.jpg"

image oldbag wave = "oldbagwave.png"
image oldbag = "oldbag.png"

$ w = Character('Wendy Oldbag', color="#c8ffc8")
$ m = Character('Me', color="#8E2323")

label start:
scene bg office

"zzzz... -Snort.- Oh! -Yawn.- I must have fallen asleep..."
m "-Sigh- As much research as I can find, nothing will help me with this court case. NOTHING. I need some tea..."

show oldbag wave

w "Edgey-pooo! There you are! I thought you were trying to avoid me again!"
"Oh god..."

show oldbag

m "Miss Oldbag, may I enquire as to what you are doing in my office?"
w "Well I wanted to come see you Edgey-poo. You never seem to come and see me anymore!!"
m "I've had my reasons Miss Oldbag, A prosecutor has a busy life, now if you'd let me get to my teapot."
w "Not until you tell me WHY you've been busy Edgey-poo!"

menu:

"Hmm... What should I do?"


"Tell her to move it.":

m "I have no reason to do to do that Oldbag. Now please move."
w "Why should I?"
m "You're in My office, and you've illegaly broken and entered."
w "..."

show oldbag at right

"Tell her why.":
m "...Okay."
jump why


"Threaten her with authority.":

m "You do realise what you have done today miss Oldbag, is calssed as breaking and entering?"
w "..."

show oldbag at right


"You walk forward and pick up your teapot, poring out some fresh hot tea. Wondering how you're going to get the old bag out of your office..."

label why:

w "Please do Edgey-Poo. An old lady like me can get curious y'know."

menu :

"Shall I? She may murder me if I tell her the truth... Who knows what the old bag can do..."

"I've been busy with my job lately miss Oldbag. Its that simple.":


"I really just don't like you.":

w "..."
m "..."
w "YOUNG PEOPLE THESE DAYS! YOU HAVE NO RESPECT FOR YOUR ELDERS!"


"I've been making sweet love to my tea.":
"Are you THAT stupid Edgeworth? She can never find out! The world will shun you... Make another choice."
I'm awfully sorry if I posted it in the wrong forum. I just Can't seem to get this to work.

What I want it to do is get the menu to work, and then have another menu for one of the options.

Jadeica
Newbie
Posts: 9
Joined: Sun Feb 10, 2008 2:26 pm
Contact:

Re: Double-Menus.

#2 Post by Jadeica »

Well. I have an account now.

Sorry for the Spoiler messing up. D:
I just can't seem to figure this out. And I've been trying for about a day now.

Guest

Re: Double-Menus.

#3 Post by Guest »

Use [ c o d e ] (without spaces in between) and [ / c o d e ] tags.

I think it's possible to do nested menus, but you would really have to pay attention to the indentations, not to mention figure out the sequence of events once you're breaking out of them.

The following is just the way I would do it... you don't have to follow it. I haven't tested the code, so just double-check the indentations if you copy and paste it (use TAB in Scite).

I usually put non main story branches in either a separate file or on top of the start label, then use jumps or calls to them. In this case, it's a call, since I want to return to the main story menu and proceed from there on.

Code: Select all

init:
    image bg office = "edgysoffice.jpg"
    image bg uni = "uni.jpg"
    image oldbag wave = "oldbagwave.png"
    image oldbag = "oldbag.png"

    $ w = Character('Wendy Oldbag', color="#c8ffc8")
    $ m = Character('Me', color="#8E2323")

label why:
    w "Please do Edgey-Poo. An old lady like me can get curious y'know."
    menu whymenu:
        "Shall I? She may murder me if I tell her the truth... Who knows what the old bag can do..."
        "I've been busy with my job lately miss Oldbag. Its that simple.":
        "I really just don't like you.":
            w "..."
            m "..."
            w "YOUNG PEOPLE THESE DAYS! YOU HAVE NO RESPECT FOR YOUR ELDERS!"
            "I've been making sweet love to my tea.":
            "Are you THAT stupid Edgeworth? She can never find out! The world will shun you... Make another choice."
    return

label start:
    scene bg office

    "zzzz... -Snort.- Oh! -Yawn.- I must have fallen asleep..."
    m "-Sigh- As much research as I can find, nothing will help me with this court case. NOTHING. I need some tea..."

    show oldbag wave
    w "Edgey-pooo! There you are! I thought you were trying to avoid me again!"
    "Oh god..."

    show oldbag

    m "Miss Oldbag, may I enquire as to what you are doing in my office?"
    w "Well I wanted to come see you Edgey-poo. You never seem to come and see me aymore!!"
    m "I've had my reasons Miss Oldbag, A prosecutor has a busy life, now if you'd let me get to my teapot."
    w "Not until you tell me WHY you've been busy Edgey-poo!"

    menu amenu:
        "Hmm... What should I do?"
        "Tell her to move it.":
            m "I have no reason to do to do that Oldbag. Now please move."
            w "Why should I?"
            m "You're in My office, and you've illegaly broken and entered."
            w "..."
            show oldbag at right
        "Tell her why.":
            m "...Okay."
            call why
        "Threaten her with authority.":
            m "You do realise what you have done today miss Oldbag, is calssed as breaking and entering?"
            w "..."
            show oldbag at right
            "You walk forward and pick up your teapot, poring out some fresh hot tea. Wondering how you're going to get the old bag out of your office..."

Jadeica
Newbie
Posts: 9
Joined: Sun Feb 10, 2008 2:26 pm
Contact:

Re: Double-Menus.

#4 Post by Jadeica »

Ah! I see now... Well kind of.

I tweeked that code a little and now it works. Thankyou for the help! :3

Jadeica
Newbie
Posts: 9
Joined: Sun Feb 10, 2008 2:26 pm
Contact:

Re: Double-Menus.

#5 Post by Jadeica »

Hmm. There seems to be another problem too now though, The first menu 'amenu' won't continue on. And Label ALWAYS brings up an error. Like This:

Code: Select all

menu amenu:
        m "(Hmm... What should I do?)"
        "Tell her to move it.":
            m "I have no reason to do to do that Oldbag. Now please move."
            w "Why should I?"
            m "You're in My office, and you've illegaly broken and entered."
            w "..."
            jump oldbag
        
        "Threaten her with authority.":
            m "You do realise what you have done today miss Oldbag, is classed as breaking and entering?"
            w "...Very well Edgey-poo."
            jump oldbag
    
        "Tell her why.":
            m "...Okay."
            call why

label oldbag
    
            show oldbag at right
            "You walk forward and pick up your teapot, poring out some fresh hot tea. Wondering how you're going to get the old bag out of your office..."  
            m "Miss Oldbag, Would you care to leave my office"
            w "..."
            m "(Dear god... If she gets angry again... Maybe her hating me is better...)"
            w "Okay Edgey-Poo."
            m "(Wow... That was awfully unseen.)"
            show oldbag wave
            w "Goodbye Edgey-Poo! I'll come and visit you again soon."
            m "(That really doesn't make me feel better...)"
           
           
I always get This Error.

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


On line 84 of C:\Documents and Settings\Jade\Desktop\renpy-6.5.0\Miles Edgeworth/game/script.rpy: expected ':' not found.
label oldbag
            ^

Ren'Py Version: Ren'Py 6.5.0e

Jadeica
Newbie
Posts: 9
Joined: Sun Feb 10, 2008 2:26 pm
Contact:

Re: Double-Menus.

#6 Post by Jadeica »

Also, I keep getting the problem with labels each time I've tried adding a label after or before a menu.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: Double-Menus.

#7 Post by PyTom »

You need to put a ':' after the name of the label.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Guest

Re: Double-Menus.

#8 Post by Guest »

Oh! Thats perfect. Thankyou. :3
I should of known it to be some minute detail.

Jadeica
Newbie
Posts: 9
Joined: Sun Feb 10, 2008 2:26 pm
Contact:

Re: Double-Menus.

#9 Post by Jadeica »

I Really am useless. To save spamming the forum, I shall just ask here.

I'm having a problem with shake here now. D: This shake just won't work, I think It MAY be because of the figures in certain areas, but the Wiki entry was rather vague with it.

Code: Select all

 $ sshake = shake((2.0, 2.0, 2.0, 2.0), 1.0, dist=15)
   python:

        import math

        class Shaker(object):

            anchors = {
                'top' : 0.0,
                'center' : 0.5,
                'bottom' : 1.0,
                'left' : 0.0,
                'right' : 1.0,
                }

            def __init__(self, start, child, dist):
                if start is None:
                    start = child.get_placement()
                #
                self.start = [ self.anchors.get(i, i) for i in start ]
                2
                self.dist = dist
                1
                self.child = child

            def __call__(self, t, sizes):
                2
                5
                def fti(x, r):
                    if x is None:
                        x = 0
                    if isinstance(x, float):
                        return int(x * r)
                    else:
                        return x

                xpos, ypos, xanchor, yanchor = [ fti(a, b) for a, b in zip(self.start, sizes) ]

                xpos = xpos - xanchor
                ypos = ypos - yanchor

                nx = xpos + (1.0-t) * self.dist * (renpy.random.random()*2-1)
                ny = ypos + (1.0-t) * self.dist * (renpy.random.random()*2-1)

                return (int(nx), int(ny), 0, 0)

        def _Shake(start, time, child=None, dist=100.0, **properties):

            move = Shaker(start, child, dist=dist)

            return renpy.display.layout.Motion(move,
                          time,
                          child,
                          add_sizes=True,
                          **properties)

        Shake = renpy.curry(_Shake)
    #

#

shake(None, 1.0, dist=5)
Sorry for being such a pain.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: Double-Menus.

#10 Post by PyTom »

Hm... you really shouldn't have to do it this way. You can shake the entire screen using "with vpunch" or "with hpunch". You can make your own transitions using MoveTransition with your own factory... you shoudn't have to write code that knows about anchors anymore.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: Double-Menus.

#11 Post by Showsni »

This is copied from the cookbook page, right? I'll try it...

Okay, this worked for me:

First, put the

Code: Select all

    python:

        import math

        class Shaker(object):

            anchors = {
                'top' : 0.0,
                'center' : 0.5,
                'bottom' : 1.0,
                'left' : 0.0,
                'right' : 1.0,
                }

            def __init__(self, start, child, dist):
                if start is None:
                    start = child.get_placement()
                #
                self.start = [ self.anchors.get(i, i) for i in start ]  # central position
                self.dist = dist    # maximum distance, in pixels, from the starting point
                self.child = child

            def __call__(self, t, sizes):
                # Float to integer... turns floating point numbers to
                # integers.
                def fti(x, r):
                    if x is None:
                        x = 0
                    if isinstance(x, float):
                        return int(x * r)
                    else:
                        return x

                xpos, ypos, xanchor, yanchor = [ fti(a, b) for a, b in zip(self.start, sizes) ]

                xpos = xpos - xanchor
                ypos = ypos - yanchor

                nx = xpos + (1.0-t) * self.dist * (renpy.random.random()*2-1)
                ny = ypos + (1.0-t) * self.dist * (renpy.random.random()*2-1)

                return (int(nx), int(ny), 0, 0)

        def _Shake(start, time, child=None, dist=100.0, **properties):

            move = Shaker(start, child, dist=dist)

            return renpy.display.layout.Motion(move,
                          time,
                          child,
                          add_sizes=True,
                          **properties)

        Shake = renpy.curry(_Shake)
    #

#
in your init block. Under that, put the

Code: Select all

    $ sshake = Shake((0, 0, 0, 0), 1.0, dist=15)
bit in your init block.

Then when you want to use a shake in your game, put something like "with sshake."

Code: Select all

with sshake

Jadeica
Newbie
Posts: 9
Joined: Sun Feb 10, 2008 2:26 pm
Contact:

Re: Double-Menus.

#12 Post by Jadeica »

PyTom: Huh? Ack, I really need to learn some more but Anchors?

Showsni:
I did that, but it keeps giving me this:

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

NameError: name 'Shake' is not defined

While executing init code:
 - script at line 2 of C:\Documents and Settings\Jade\Desktop\renpy-6.5.0\Miles Edgeworth/game/script.rpy
 - python at line 2 of C:\Documents and Settings\Jade\Desktop\renpy-6.5.0\Miles Edgeworth/game/script.rpy.
My Init is now like this.

Code: Select all

nit:
    $ sshake = Shake((0, 0, 0, 0), 1.0, dist=15)
    
    image bg office = "edgysoffice.jpg"
    image bg uni = "uni.jpg"
    image bg black = "black.jpg"
    image oldbag wave = "oldbagwave.png"
    image oldbag = "oldbag.png"
    image oldbagmad = "oldbagangry.png"
    
    $ w = Character('Wendy Oldbag', color="#c8ffc8")
    $ m = Character('Edgeworth', color="#8E2323")
The Python I put in place.
And the tag...

Code: Select all

    m "(That really doesn't make me feel better...)"
            "As Oldbag leaves the office you sigh, taking a sip of your raspberry tea. As you look at your expensive gold watch you realise the time, 3.45. Court is in session in 15 minuets and it takes 30 to get there. Upon realisation you spit out your tea, unfortunatly you spit it out all over your trousers and crotch. But having no time to change you arise from the desk you were leant against and sort out you scruffy morning hair. A Prosecutor can't be seen in a state remember."
            
            with sshake
            
            m "No No No! This can not be happening. WHERE ARE MY CASE FILES?!"
            "Normally Miles Edgeworth is cool, calm and collective, but when no one else is             around and something like This comes up... Theres exceptions, even for Miles Edgeworth."
           

Jadeica
Newbie
Posts: 9
Joined: Sun Feb 10, 2008 2:26 pm
Contact:

Re: Double-Menus.

#13 Post by Jadeica »

No help? Sorry for being so consistent, I really cannot figure this out. D:

herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

Re: Double-Menus.

#14 Post by herenvardo »

Well, I've not tried this code, but since I've crashed Ren'py in several hundred different ways, I think I'll be able to help you :P
Showsni wrote: First, put the

Code: Select all

    python:

        import math

        class Shaker(object):

            anchors = {
                'top' : 0.0,
                'center' : 0.5,
                'bottom' : 1.0,
                'left' : 0.0,
                'right' : 1.0,
                }

            def __init__(self, start, child, dist):
                if start is None:
                    start = child.get_placement()
                #
                self.start = [ self.anchors.get(i, i) for i in start ]  # central position
                self.dist = dist    # maximum distance, in pixels, from the starting point
                self.child = child

            def __call__(self, t, sizes):
                # Float to integer... turns floating point numbers to
                # integers.
                def fti(x, r):
                    if x is None:
                        x = 0
                    if isinstance(x, float):
                        return int(x * r)
                    else:
                        return x

                xpos, ypos, xanchor, yanchor = [ fti(a, b) for a, b in zip(self.start, sizes) ]

                xpos = xpos - xanchor
                ypos = ypos - yanchor

                nx = xpos + (1.0-t) * self.dist * (renpy.random.random()*2-1)
                ny = ypos + (1.0-t) * self.dist * (renpy.random.random()*2-1)

                return (int(nx), int(ny), 0, 0)

        def _Shake(start, time, child=None, dist=100.0, **properties):

            move = Shaker(start, child, dist=dist)

            return renpy.display.layout.Motion(move,
                          time,
                          child,
                          add_sizes=True,
                          **properties)

        Shake = renpy.curry(_Shake)
in your init block.
Did you put this on your init, as Showsni suggested? It looks like you didn't, since the init block you posted here doesn't include that. And this would explain your problem: note that the last line is defining the variable Shake, you are not including it, and you have an error saying that "name 'Shake' is not defined". So put in this piece of code, which defines 'Shake', and then Shake will be defined.. again, I've not tried the code; but I'll trust Showsni ;)
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

Jadeica
Newbie
Posts: 9
Joined: Sun Feb 10, 2008 2:26 pm
Contact:

Re: Double-Menus.

#15 Post by Jadeica »

Ahha! I thought it had gone into Init, but seems it hadn't. Thankyou for your help. But is there a way of making the text and picture stay on too?

Post Reply

Who is online

Users browsing this forum: Google [Bot]