Trouble making a button close a menu and jump to a script location

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
Gnik
Newbie
Posts: 4
Joined: Sun Feb 23, 2020 8:03 pm
Contact:

Trouble making a button close a menu and jump to a script location

#1 Post by Gnik »

I'm fairly new to using Ren'Py so I'm not sure if I'm missing something obvious here, but I've been trying for about a week to get this one thing down.

Simply put, I have a menu where you click of a few buttons that set variables. What I'm stuck on is that I want when you close the menu for it to jump you to a different part in the script depending on what you clicked on. I first got it to close, then I tried adding another action, but somehow I can't even get it to close anymore. I'm not sure what I'm missing.

This is what I have in the screens file:

Code: Select all

screen AmuletMenu():
    zorder 100
    tag menu
    
    style_prefix "AmuletMenu"
    
    frame:
        xpadding 10
        ypadding 10
        xalign 0.5
        yalign 0.0

        button:
            action [jump(noanswe), return()]
            text _("go")
When I try to run the game it gives me this:

Code: Select all


File "game/screens.rpy", line 1560: u'return' is not a keyword argument or valid child for the button statement.
    action return()

Any help would be appreciated.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Trouble making a button close a menu and jump to a script location

#2 Post by Imperf3kt »

the return action requires a capital R
Return()
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Gnik
Newbie
Posts: 4
Joined: Sun Feb 23, 2020 8:03 pm
Contact:

Re: Trouble making a button close a menu and jump to a script location

#3 Post by Gnik »

Thanks Imper3kt. I had a feeling it was something simple. That looks like it did the trick.

Gnik
Newbie
Posts: 4
Joined: Sun Feb 23, 2020 8:03 pm
Contact:

Re: Trouble making a button close a menu and jump to a script location

#4 Post by Gnik »

Now that the game doesn't crash, I ran into a different problem. Instead of going to the place I want it to in the script, it sort of overlays it, for lack of a better word. In short, it will play out the script I jump to within the menu instead of closing the menu it's in when it jumps. It even keeps the buttons I have in the menu. I was hoping I could get it to jump to a determined part of the script in the same way that it would if jumping outside of a menu. One notable thing is that I can right click and it will go back to where I was before entering the menu the button is in.

For regeneracy, this is the code. I made slight change so figured I'd include it to be safe.

Code: Select all

 button:
            action [Jump("stage1"),Return()]
            text _("go")

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Trouble making a button close a menu and jump to a script location

#5 Post by Imperf3kt »

How have you shown the menu, the Return() function assumes you used a call, but if you simply used show, then that method won't work, instead use [Hide screen "Amulet_menu", Jump "stage"]

I'm not 100% positive on the syntax, and I'm away from a PC right now, so I can't verify that's correct.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Gnik
Newbie
Posts: 4
Joined: Sun Feb 23, 2020 8:03 pm
Contact:

Re: Trouble making a button close a menu and jump to a script location

#6 Post by Gnik »

I had been using ShowMenu which prevents the previous text from showing, but seems to be what makes the duplicate instances of the game's script. I tried Show which doesn't create the duplicate scripts, but I can't get the textbuttons to go away, I tried using hide, but no success. I tried changing it to use call, and that one just crashes the game.

I also tried making it so you enter the menu just to set variables, and then make a new button to use the variables to determine where to jump to, but it says my syntax is wrong, and I can't see why. I think this last way is going to be the cleanest once I start adding a bunch of variables in. For this, ShowMenu works perfectly. Since my new issues are completely different issues I'll work on it and then post a new question if I need to.

Post Reply

Who is online

Users browsing this forum: Alex, Google [Bot]