Stopping advancement at custom 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.
Post Reply
Message
Author
User avatar
Chibi Kami
Newbie
Posts: 8
Joined: Thu Jun 12, 2008 12:19 am
Projects: Mad Science Experiment (unfinished)
Contact:

Stopping advancement at custom menus

#1 Post by Chibi Kami » Tue Jun 24, 2008 3:25 pm

Okay, I've developed a pretty good custom menu here, with just one slight problem: It wants to continue onward to the next line of the script if i click anywhere but a text button. I need to know how to terminate the advancement.
If we can complete this, I think it'd make a worthy addition to the cookbook.

Code: Select all

#this formula will create a statistics menu on the left and a command menu on the right. It is suitable for classic location-based adventure games (with move and use commands, etc.) or for training sims. The statistics will be numerical instead of a bar under this formula.
#For the sake of argument, you could call these stats HP, MP, etc.

$ stat1 = 0
$ stat2 = 0
$ stat3 = 0

    Python:
        #first window
        #forces size of frame to not exceed stated pixel width.
        #Also sets the initial coordinate anchor point for all items to 10 pixels in from the edge.
        #Bet you didn't know it could be used like that, huh?

        ui.sizer(xpos=10, ypos=10, maxwidth=200)
        ui.frame(xpos=0,
                ypos=0,
                xanchor='left',
                yanchor='top',
                xfill=True)

        ui.vbox(xpos=0,
                xanchor='left')

        ui.text("Stats") #used for category

        ui.text("statname: %(stat1)d" % globals())

        ui.text("statname: %(stat2)d" % globals())

        ui.text("statname: %(stat3)d" % globals())

        ui.close()

        #second window
        #setting up this one is what made using the x and y pos arguments necessary.
        #I kept getting text without a box while the max width was set to 200,
        #because it was limiting where the box was capable of being displayed at x200.

        ui.sizer(xpos=590, ypos=10, maxwidth=200) 


        ui.frame(xpos=0,
                ypos=0,
                xanchor='left',
                yanchor='top',
                xfill=True) 

        ui.vbox(xpos=0,
                xanchor='left')
        #these create menu buttons within the box. They should appear in descending order on the right side of the screen.
        ui.textbutton("Option 1", clicked=ui.returns(1))
        ui.textbutton("Option 2", clicked=ui.returns(2))
        ui.textbutton("Option 3", clicked=ui.returns(3))
        ui.close()

        #not certain, but I think you can call this "result" variable whatever you want

        result = ui.interact()
        if result == 1:
            #commands go here. submenus, jumps, speech, whatever
        if result == 2:

        if result == 3:

There we go. The only problem is that it doesn't halt forward momentum of the script. I gather I should probably make it a python hide command instead of normal python, but I don't quite get how to define it so it can be called and even if i did, I don't think that alone would prevent the continuation.

In any case, if you were to use this script in an adventure game, you'd want to set it up individually for each location so you can set up north, south, east, west commands more easily.

Well, that's enough talk on it. Solutions for the minor flaw are greatly appreciated, as is abject praise. =P

User avatar
JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Stopping advancement at custom menus

#2 Post by JQuartz » Wed Jun 25, 2008 1:18 am

I'm not really sure what's the minor flaw you mentioned but my guess is (correct me if I'm wrong)you want to keep it on screen all the time. If this is really what you want then you could use the overlay function:
http://www.renpy.org/wiki/renpy/doc/reference/Overlays
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

User avatar
Chibi Kami
Newbie
Posts: 8
Joined: Thu Jun 12, 2008 12:19 am
Projects: Mad Science Experiment (unfinished)
Contact:

Re: Stopping advancement at custom menus

#3 Post by Chibi Kami » Wed Jun 25, 2008 8:01 pm

Uh, sorry, guessed wrong. I'm pretty sure I said it before, but it may have been tl;dr (or maybe I shouldn't have said minor flaw in a manor that implies it's unrelated to teh initially stated problem. I dunno)

Anyway, the problem is that I can click anywhere on the screen that's not a designated button when the menu comes up, the menu dissappears, and the script continues executing in natural order.

The sample DSE in the renpy demo tutorial makes you click the dismiss button to continue. I'm trying to figure out what makes it stop executing script and wait for button input.

Although, the overlay option sounds like a good idea for adventure games, but only if I want the menu to always be there. It would also require seperate calls for the menu buttons, I'd have to disable them midspeech, and I'd still need to make the script stop executing. The problem persists.

Hmm....It became tl;dr again....

maselphie
Regular
Posts: 71
Joined: Fri May 23, 2008 2:12 pm
Projects: By The Lake, Seraphine
Location: USA
Contact:

Re: Stopping advancement at custom menus

#4 Post by maselphie » Wed Jun 25, 2008 10:01 pm

Look at the bottom of "day_planner.rpy" again. A large portion of the script seems to be dedicated to this -- it's rather hard to miss, actually.
I have switched accounts to Aleema.

User avatar
JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Stopping advancement at custom menus

#5 Post by JQuartz » Wed Jun 25, 2008 10:25 pm

Chibi Kami wrote:Anyway, the problem is that I can click anywhere on the screen that's not a designated button when the menu comes up, the menu dissappears, and the script continues executing in natural order.
Eh...I can't reproduce the problem using the code you posted. I have to click on one of the three buttons in order to advance the script.
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

Nova Alamak
Regular
Posts: 71
Joined: Sun Jun 08, 2014 1:45 pm
Contact:

Re: Stopping advancement at custom menus

#6 Post by Nova Alamak » Wed Jul 23, 2014 3:13 pm

I'm having this problem too! My menus are just screens though. If they're displayed, all I want to do is keep the player from moving on with the story while they're open. Lots of people have recommended disabling the mouse, but that would A) not disable the spacebar advance and B) keep them from being able to interact with the custom menu itself. Isn't there a way to just pause the text until you tell it to enable again?

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Stopping advancement at custom menus

#7 Post by Alex » Wed Jul 23, 2014 3:21 pm

You could either 1) add <modal True> parameter to your screen to force player to operate with this screen only, or 2) call your screen instead of showing it, so player will interact with this screen untill it returns anything.

http://www.renpy.org/doc/html/screens.h ... -statement
http://www.renpy.org/doc/html/screens.html#call-screen

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Stopping advancement at custom menus

#8 Post by xela » Wed Jul 23, 2014 3:27 pm

Alex wrote:You could either 1) add <modal True> parameter to your screen to force player to operate with this screen only, or 2) call your screen instead of showing it, so player will interact with this screen untill it returns anything.

http://www.renpy.org/doc/html/screens.h ... -statement
http://www.renpy.org/doc/html/screens.html#call-screen
I think he/she puts this directly on label...

Code: Select all

    python:
        #first window
        #forces size of frame to not exceed stated pixel width.
        #Also sets the initial coordinate anchor point for all items to 10 pixels in from the edge.
        #Bet you didn't know it could be used like that, huh?
        while 1:
            # Ui code
    
            #not certain, but I think you can call this "result" variable whatever you want
    
            result = ui.interact()
            
            if isinstace(result, int):
                break
            else:
                pass
            
            # If this doesn't work, remove the fork above and uncomment the one below:
            
            # if result in [1, 2, 3]:
                # break
            # else:
                # pass
        
        
        if result == 1:
            #commands go here. submenus, jumps, speech, whatever
        if result == 2:

        if result == 3:
Please do not put this in the cookbook, this code style is ancient.
Like what we're doing? Support us at:
Image

Nova Alamak
Regular
Posts: 71
Joined: Sun Jun 08, 2014 1:45 pm
Contact:

Re: Stopping advancement at custom menus

#9 Post by Nova Alamak » Wed Jul 23, 2014 3:34 pm

Thank you very much, Alex! The call statement strategy is just what I needed. I think I'm on the right track now!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Ocelot, Sergei Falcon