What I'd like to do is make a menu at the start of the game to select a character to play with. I know how to do that but I don't know how to make a menu (and keep character's/routes locked until a specific route is completed).
example of what I would like to do
thanks in advance. .___.
selectable char menu?
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.
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.
- killdream
- Veteran
- Posts: 325
- Joined: Wed Nov 05, 2008 1:05 pm
- Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
- Deviantart: robotlolita
- Github: robotlolita
- Location: World's End (aka Brazil)
- Contact:
Re: selectable char menu?
You can use ui functions for this, and use Persistent data to see if a route is or not completed.
To enable some character, just set the persistent variable to that character. Like, say, you beat the character 1 route, then on the end of that route you'd put some code like this:
Code: Select all
label char_select:
python:
# this function takes care of creating the clickable character buttons ^^
def char_slot(char_image, char_image_locked, locked, result):
# char_image is the image of the character
# char_image_locked is the image used when the character is locked (like a grayscale picture of they)
# locked is a boolean (True or False) value that indicates if the character is locked or not
# result is the value returned when the user clicks on the character
if locked:
image = char_image_locked
image_over = char_image_locked
clicked = None
else:
image = char_image
image_over = im.MatrixColor(image, im.matrix.brightness(.15))
clicked = ui.returns(result)
ui.imagebutton(image, image_over, clicked=clicked)
# here we add the characters to the screen.
ui.hbox(spacing=5)
char_slot("character1.png", "character1_locked.png", False, "char1") # the first character will be always available
char_slot("character2.png", "character2_locked.png", (not persistent.char1_route), "char2") # the second character will be available only if the user completed the first character route
# third and fourth character will be available after the user completed the character 2 route
char_slot("character3.png", "character3_locked.png", (not persistent.char2_route), "char3")
char_slot("character4.png", "character4_locked.png", (not persistent.char2_route), "char4")
ui.close() # closes the hbox
selection = ui.interact(suppress_overlay=True, suppress_underlay=True) # don't let the user calls the menu in this selection
if selection == "char1":
ui.jumps("char1_start")
elif selection == "char2":
ui.jumps("char2_start")
elif selection == "char3":
ui.jumps("char3_start")
elif selection == "char4":
ui.jumps("char4_start")
Code: Select all
$ persistent.char1_route = True
-
- Regular
- Posts: 131
- Joined: Sun Feb 08, 2009 2:00 pm
- Projects: Restriction
- Location: Belarus,Minsk
- Contact:
Re: selectable char menu?
in this situation, i think, the better solution use the MultiPersistent.
Returned
Who is online
Users browsing this forum: Ocelot