Choice menu with return? [Solved]

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
h0tWalker
Newbie
Posts: 7
Joined: Fri Jun 13, 2014 3:02 pm
Contact:

Choice menu with return? [Solved]

#1 Post by h0tWalker »

So i try to make a game here where you have a menu that leads to another menu. In the second menu i wish to have a return function, so that if you meant to hit something else, you may return to the previous choice menu and select what you really meant to be choosing.

Example

menu:
"Use Computer":
jump computer
"Check Bookshelf":
jump bookshelf
"Rest":
jump rest
"Go Outside":
jump gooutside

label computer:
menu:
"Work on game":
jump workgame
"Shop Online":
jump shoponline
"Don't use the computer":
->What to do here? T_T<-

So i try to make it so that if you don't want to use the computer, then you can jump back to the previous menu and eventually chose to go outside instead.

I also try to have this in a separate document i call "Choice_Menu.rpy" but i don't really know how to link it up either. I am new to renpy, and I've looked over the tutorial and tried googeling, but all examples just show how to make a simple choice and make it work with the "Jump" and "Labels" functions, which is easy enough. However, these two things i ask for help with here is something I'm not capable of. I'm tired of googeling and browsing trough every forum page, cuz i haven't found it anywhere so far, and I'm just so full of anger now for not being able to fix this problem past the two days...

If anyone can manage to help me, then really, i appreciate it.

-Sincerely, Walker
Last edited by h0tWalker on Sat Jun 14, 2014 2:40 am, edited 1 time in total.

Valmoer
Regular
Posts: 53
Joined: Sat Feb 04, 2012 9:46 pm
Contact:

Re: Choice menu with return?

#2 Post by Valmoer »

Hello Walker,

First things first, welcome to the Lemma Soft forums! I hope you'll have fun creating your ren'py games :)

As a helpful hint, you have, while posting your posts, accesss to the Code button that gives you access to the [code][/code], which allows you to post code with the indentation kept. Given how crucial indentation is in Ren'py and Python : it's pretty damn useful.

Your code so becomes :

Code: Select all

menu:
	"Use Computer":
		jump computer
	"Check Bookshelf":
		jump bookshelf
	"Rest":
		jump rest
	"Go Outside":
		 jump gooutside

label computer:
	menu:
		"Work on game":
			jump workgame
		"Shop Online":
			jump shoponline
		"Don't use the computer":
			->What to do here? T_T<-
So to get back to your question : you have to jump back to your first menu, or a point just before. So do that, jump to a named label that you place before your menu.

But wait, there's more!

Do you know that menu tags double as labels ?
You can therefore name your first menu activity and drop your computer label and name your second menu computer, and your code now becomes

Code: Select all

menu activity:
	"Use Computer":
		jump computer
	"Check Bookshelf":
		jump bookshelf
	"Rest":
		jump rest
	"Go Outside":
		 jump gooutside

menu computer:
	"Work on game":
		jump workgame
	"Shop Online":
		jump shoponline
	"Don't use the computer":
		jump activity
Hope it helps. This code has been tested and should work as you desire.
Last edited by Valmoer on Fri Jun 13, 2014 4:15 pm, edited 1 time in total.

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Choice menu with return?

#3 Post by wyverngem »

Code: Select all

label ChoiceLopp:
    menu:
        "Go outside":
            jump gooutside
        "More":
            jump More
jump ChoiceLoop

label More:
        "Use computer":
            jump usecomputer
        "Go back":
            jump ChoiceLoop
You need to make a loop label. When you jump to the label of your choice you can choose at the end to jump back the loo label or more on. Make sense?

h0tWalker
Newbie
Posts: 7
Joined: Fri Jun 13, 2014 3:02 pm
Contact:

Re: Choice menu with return?

#4 Post by h0tWalker »

Thanks a bunch both of you!
I was struggling so long with this, and now i can finally continue. I was so restless because i couldn't do anything until i had the menu in box, and you guys saved me :)

But as for linking this one up to the game, so i don't have to re-type it all the time (more or less copy / paste), do you know a solution for that? Because i use the Dating Sim Engine, and also gonna take use of connecting it up to the event.rpy file and skip the day planner :)

Again, thanks a bunch, sincerely, Walker

Valmoer
Regular
Posts: 53
Joined: Sat Feb 04, 2012 9:46 pm
Contact:

Re: Choice menu with return?

#5 Post by Valmoer »

You'll have to be a little more specific than that. I'm not sure I understand your need well enough from what you said (and I wouldn't want to give you an half-assed answer that didn't fit you solution either :p ). Would you mind giving us an in-situation example ?

h0tWalker
Newbie
Posts: 7
Joined: Fri Jun 13, 2014 3:02 pm
Contact:

Re: Choice menu with return?

#6 Post by h0tWalker »

ah, yea, atm i have some difficulties with my "script" menu. I have a menu which has choices leading to another menu with more choices. This is what the played will spend most time at (when it comes to choices). I have a file where it says "Label Start" and at the bottom it says "Return".

Now, it's 100 lines in total atm, and instead of repeating these 100 lines over and over in the main script, i really want to make it possible just to call the "Choice_Menu.rpy" script as i call it into the "Main.rpy" script.

so it's generally just like the normal script with label start and return, except it just have a menu (choices) to make such as "use computer" and "Go outside" which again lead to a menu on what you want to do on the computer and where you want to go.

It's like the Dating Sim Engine where it calls for the "Day_Planner.rpy" or tutorial where it calls all the "Demo.rpy" files which i couldn't make sense of :s

thanks for taking your time, sincerely, Walker

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Choice menu with return?

#7 Post by trooper6 »

I am no Ren'py master...but I use multiple files in my game, so I'll try to clarify what I think may be an error in your thinking.

Multiple files are just for us. The Ren'py programs treats all the .rpy files as if there were just one big file.
This means that you should only have one label start. That should be in your main .rpy file...which is script.rpy
The start means: This is where the game starts after the main menu.

After the game starts, every things else is jumping and calling. It doesn't matter if you jump to a block in the same file or a different file, it is all the same to ren'py. So you don't call the "Choice_Menu.rpy" file you just jump or call to the blocks you've put in that file.

You don't have to do anything special or repeat 100s of lines of text, just jump or call to the block you've written.

Small side note: There are two commands to move to a different block: jump and call.
jump just goes to that place.
call goes to that place and comes back to where it came from when it hits a return at the end of the block.
This is all detailed here:
http://www.renpy.org/doc/html/label.html
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

h0tWalker
Newbie
Posts: 7
Joined: Fri Jun 13, 2014 3:02 pm
Contact:

Re: Choice menu with return?

#8 Post by h0tWalker »

Thanks a bunch trooper6!

I can rest a little at ease now, and put my mind of this at work, especially as i will work a 10 hour shift!
I will try it when i come home, and really, thanks. Now i have one less thing to worry about :)

-Sincerely, Walker

Post Reply

Who is online

Users browsing this forum: Bing [Bot]