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.
-
LeviathanXyzzy
- Newbie
- Posts: 1
- Joined: Tue Jul 25, 2017 4:14 am
- Tumblr: LeviathanXyzzy
-
Contact:
#1
Post
by LeviathanXyzzy » Tue Jul 25, 2017 4:21 am
Hello, I'm a little new to Ren'py, and I need a little help. I'm using a menu and flags to remove the choices once they've been picked, but I can't get a final option to pop up once all of them have been picked.
For example, once library, general store, bar and diner, and walk around have been chosen, I want the option of 'Go to cabin' to pop up. Any ideas?
Code: Select all
label lookaroundmenu:
menu:
nar "Where should you go to first?"
"The Library." if library_visited_done == False:
$ library_visited_done = True
jump thelibrary
"The General Store." if generalstore_visited_done == False:
$ generalstore_visited_done = True
jump generalstore
"The Bar and Diner." if baranddiner_visited_done == False:
$ baranddiner_visited_done = True
jump baranddiner
"Walk around." if walkaround_done == False:
$ walkaround_done = True
jump walkaround
label thelibrary:
nar "You walked to the rather small library, interested in if it had anything instore for you."
jump lookaroundmenu
label generalstore:
nar "You walked up the short steps to the general store, taking note of the fresh red paint on the porch. Maybe they were renovating a bit?"
jump lookaroundmenu
label baranddiner:
nar "Your stomach had been growling not too long ago. Maybe something to eat would satisfy you?"
jump lookaroundmenu
label walkaround:
nar "You choose to walk around, interested in the sights."
nar "You found there to be a town hall, which might actually have some answers about this places history."
jump lookaroundmenu
label chooseagain:
nar "You've already done that. Try again."
jump lookaroundmenu
return
-
warmsundae
- Regular
- Posts: 61
- Joined: Tue Feb 24, 2015 9:51 pm
- Skype: electriclan
- Soundcloud: lanterny
- Location: korea
-
Contact:
#2
Post
by warmsundae » Tue Jul 25, 2017 5:55 am
I hope there's a simpler method, but here's what I would do:
Code: Select all
label lookaroundmenu:
if library_visited_done:
if generalstore_visited_done:
if baranddiner_visited_done:
if walkaround_done:
$ gotocabin = True
else:
pass
else:
pass
else:
pass
else:
pass
menu:
nar "Where should you go to first?"
"The Library." if library_visited_done == False:
$ library_visited_done = True
jump thelibrary
"The General Store." if generalstore_visited_done == False:
$ generalstore_visited_done = True
jump generalstore
"The Bar and Diner." if baranddiner_visited_done == False:
$ baranddiner_visited_done = True
jump baranddiner
"Walk around." if walkaround_done == False:
$ walkaround_done = True
jump walkaround
"Go to cabin." if gotocabin == True:
jump gotocabin
also, you can label menus like
but I can't remember if you can put "if/else" code after a menu label.
-
Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
-
Contact:
#3
Post
by Remix » Tue Jul 25, 2017 6:34 am
Inline in the menu should be fine
Code: Select all
"Go to cabin." if walkaround_done and baranddiner_done and etc etc:
jump gotocabin
-
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:
#4
Post
by wyverngem » Tue Jul 25, 2017 6:41 am
Much easier to do Remix's line and I would go with that. @warmsundae You can use and and or on if conditions so you don't have to write the code like you did. This suffices.
Code: Select all
if library_visited_done == True and generalstore_visited_done == True and baranddiner_visited_done == True and walkaround_done == True:
jump my_label
There's really no need to write an else statement if it's going to be blank. Only if it does something.
-
shin.e.d
- Newbie
- Posts: 22
- Joined: Sat Jan 10, 2015 10:50 am
- Projects: Data Lion and an unnamed bxb game with dinosaurs!
-
Contact:
#5
Post
by shin.e.d » Wed Jul 26, 2017 12:23 am
There's an undocumented feature in menus that'll remove choices automatically.
(first found it mentioned by Ocelot
over in this thread.)
So you can potentially write something like this:
Code: Select all
## Use default to declare some variables to be used in the script.
default visited=[]
default jogged=False
label menu_loop:
menu:
## this variable holds a list of the choices chosen and hides them.
set visited
"The Library.":
call thelibrary2
jump menu_loop
"The General Store.":
call generalstore2
jump menu_loop
"The Bar and Diner.":
call baranddiner2
jump menu_loop
"Walk around." if not jogged: ## if statements still work too.
call walkaround2
jump menu_loop
"or jog around!" if not "Walk around." in visited: ## also this.
$jogged=True
"You found the town's town hall and got some good exercise too."
jump menu_loop
## The game continues down here if there's no jump statement,
## or when the above menu is out of choices.
menu:
"Go to cabin.":
"You head back to the cabin."
## this return ends the game if the call stack is empty.
return
## Note that if you use the same 'set name_here' again with another menu it
## would have the problem of hiding choices that were picked before.
## So either use a new variable everytime or reset it with this: $visited=[]
label thelibrary2:
"You walked to the rather small library, interested in if it had anything instore for you."
return
label generalstore2:
"You walked up the short steps to the general store, taking note of the fresh
red paint on the porch. Maybe they were renovating a bit?"
return
label baranddiner2:
"Your stomach had been growling not too long ago. Maybe something to eat would satisfy you?"
return
label walkaround2:
"You choose to walk around, interested in the sights."
"You found there to be a town hall, which might actually have some answers about this places history."
return
Users browsing this forum: Bing [Bot], Google [Bot], Ocelot, zyric