Hide menu choices until required item is in inventory 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
nutmeg2736
Newbie
Posts: 2
Joined: Sat Oct 20, 2007 1:29 am
Contact:

Hide menu choices until required item is in inventory SOLVED

#1 Post by nutmeg2736 »

I'm trying to make it so players can change the clothing and equipment of the character by selecting it as a choice in a menu. Unfortunately, I don't know how to make the choices show only the clothes that the player has in the inventory so right now it's just showing all the items in the game. I've got it so that if the player selects an item that hasn't been purchased yet, it just says "You don't own that." But it takes a lot of the fun out when the player sees all those items then finds out s/he doesn't own any of them.

What I did:

Code: Select all

$ weapons = []
$ equipment = "Bare Fists"

menu:
                            "Copper Blade":
                                if "Copper Blade" in weapons:
                                    "%(povname)s equipped herself with the Copper Blade. +10 Combat"
                                    $ equipment = "Copper Blade"
                                    jump choices
                                else:
                                    "%(povname)s doesn't own that weapon."
                                    jump choices
                            "Iron Broadsword":
                                if "Iron Broadsword" in weapons:
                                    "%(povname)s equipped herself with the Copper Blade. +20 Combat"
                                    $ equipment = "Iron Broadsword"
                                    jump choices
                                else:
                                    "%(povname)s doesn't own that weapon."
                                    jump choices
                            "Unequip Weapon":
                                "%(povname)s no longer carries any weapons."
                                $ equipment = "Bare Fists"
                                jump choices
                            "Nevermind":
                                jump choices
So what I have a problem with is how you can see all the choices, even if you don't have any of those weapons or have any weapons equipped. It's silly to try and unequip your bare fists. Anyone have any tips?
Last edited by nutmeg2736 on Fri Jun 08, 2012 4:51 pm, edited 1 time in total.

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: Hide menu choices until required item is in inventory

#2 Post by Showsni »

Just change the if bit to the lines showing the choices in the menu.

Code: Select all

menu:
                            "Copper Blade" if "Copper Blade" in weapons:
                                    "%(povname)s equipped herself with the Copper Blade. +10 Combat"
                                    $ equipment = "Copper Blade"
                                    jump choices
                            "Iron Broadsword" if "Iron Broadsword" in weapons:
                                    "%(povname)s equipped herself with the Iron Blade. +20 Combat"
                                    $ equipment = "Iron Broadsword"
                                    jump choices
                            "Unequip Weapon" if not equipment == "Bare Fists":
                                "%(povname)s no longer carries any weapons."
                                $ equipment = "Bare Fists"
                                jump choices
                            "Nevermind":
                                jump choices

nutmeg2736
Newbie
Posts: 2
Joined: Sat Oct 20, 2007 1:29 am
Contact:

Re: Hide menu choices until required item is in inventory

#3 Post by nutmeg2736 »

Awesome, thanks! That makes everything so much easier.

Post Reply

Who is online

Users browsing this forum: No registered users