Creating a menu with If options having some bugs

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
User avatar
WhiteMageChiu
Regular
Posts: 35
Joined: Thu Dec 12, 2013 8:35 pm
Completed: Two Steps Back
Projects: I Woke Up Because it Hurt, A Case of Two Souls Becoming One, In Which I Was Never the Hero
Organization: CureAll
Tumblr: chiuscanvas
Deviantart: inuyashatoysrule
Location: [The World]
Contact:

Creating a menu with If options having some bugs

#1 Post by WhiteMageChiu » Tue Feb 24, 2015 2:32 pm

Code: Select all

menu: 
            
            "Throw what's in the fridge." if "blood" in items:
                jump bad
            
            "Throw the knife down." if "knife" in items:
                jump bad1
            
            "Throw the rope down." if "rope" in items: 
                jump bad2
            
            "Yell down at them.":
                jump bad3 
            
So here's what's going on-- in game you're exploring around a house and collecting items as you go, when you get to this point you can interact with a particular situation with the items you have collected.
But it's possible you wouldn't have collected them all, thus the "if" statements with the item inventory.

While playing, collecting the items seems to be working just fine, the problem I'm seeing is this:

The 'throw the rope down' bit always shows as a menu option, but then even if I collect every other collectible item, only the one I collected most recently shows as an option.

If you need to see more of my code to understand better where the problem is, please let me know and I'll provide more.
Hopefully this makes sense, thank you for your time and help.
https://twitter.com/CureAllChiu
http://www.chiuscanvas.tumblr.com

Keep updated on my horror/ mystery visual novel [I Woke Up Because It Hurt!]
[Currently @ 20% completion- chugging along on coding, art, music. Writing completed]

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

Re: Creating a menu with If options having some bugs

#2 Post by trooper6 » Tue Feb 24, 2015 4:06 pm

I just did a test of your concept and didn't have any problems getting it to work. This is exactly what I did so you can see if you did something different. Note, I made the menu loop so I could test adding and removing items. Everything is working.

Code: Select all

label start:
    $ items = set()

    call fridge
    $items.add("blood")
    call fridge
    $items.add("knife")
    call fridge
    $items.add("rope")   
    call fridge
    $items.remove("rope")
    call fridge
    $items.discard("blood")  
    call fridge
    $items.remove("knife")    
    call fridge
 
    return
    
menu fridge:
    "Throw what's in the fridge." if "blood" in items:
        "jump bad"
    "Throw the knife down." if "knife" in items:
        "jump bad1"
    "Throw the rope down." if "rope" in items: 
        "jump bad2"
    "Yell down at them.":
        "jump bad3" 
    
return
I hope seeing a working version of your code will help you figure out what you are doing in your program!
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

User avatar
WhiteMageChiu
Regular
Posts: 35
Joined: Thu Dec 12, 2013 8:35 pm
Completed: Two Steps Back
Projects: I Woke Up Because it Hurt, A Case of Two Souls Becoming One, In Which I Was Never the Hero
Organization: CureAll
Tumblr: chiuscanvas
Deviantart: inuyashatoysrule
Location: [The World]
Contact:

Re: Creating a menu with If options having some bugs

#3 Post by WhiteMageChiu » Tue Feb 24, 2015 8:14 pm

You are such a trooper!! Thank you so so much!
[Please, forgive me, I cannot resist a pun so opportune]

I think what my problem was, was that for some reason [really not sure why I did] I placed a (set) every single time you entered a place that would get you an item. So I think it was over-ridding all previous sets each time you got an item.

It is running oh so smoothly now, seeing your mock up helped a lot so thank you very very much! <3
https://twitter.com/CureAllChiu
http://www.chiuscanvas.tumblr.com

Keep updated on my horror/ mystery visual novel [I Woke Up Because It Hurt!]
[Currently @ 20% completion- chugging along on coding, art, music. Writing completed]

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

Re: Creating a menu with If options having some bugs

#4 Post by trooper6 » Tue Feb 24, 2015 10:11 pm

I love puns, so they are always welcome!!

I'm glad you got it to work. I had noticed that your menu didn't seem to have the right indentation--but good that you figured out the set problem!
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

Post Reply

Who is online

Users browsing this forum: gas, RicharDann