Page 1 of 1

Creating a menu with If options having some bugs

Posted: Tue Feb 24, 2015 2:32 pm
by WhiteMageChiu

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.

Re: Creating a menu with If options having some bugs

Posted: Tue Feb 24, 2015 4:06 pm
by trooper6
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!

Re: Creating a menu with If options having some bugs

Posted: Tue Feb 24, 2015 8:14 pm
by WhiteMageChiu
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

Re: Creating a menu with If options having some bugs

Posted: Tue Feb 24, 2015 10:11 pm
by trooper6
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!