A door with many keys?

Help me.PNG
Please.PNG
Hello, I'm new to rmmv and trying to make a small game for a friend (And for practice) using no plugins or outside scripts.
What gave me an issue was when I tried to make a locked door with two possible keys.
Both keys are supposed to work. But, the key the player uses will change the story down the line.
Every time I try to use the code the way my tiny brain tells me it should work, the game crashes and doesn't do the thing.
Is there a tutorial out there that can help me or a similar thread I can be directed towards?
I think it would help if you posted a screen shot of the event where you are trying to do this so that we can see what's happening. Don't crop it, as we need the information down the left side as well as the commands themselves. If there is more than one page, then we will need a screen shot of each one. Please use Alt+PrtSc to take the shot, so that only the active window is included, not your whole desk top.
I think it would help if you posted a screen shot of the event where you are trying to do this so that we can see what's happening. Don't crop it, as we need the information down the left side as well as the commands themselves. If there is more than one page, then we will need a screen shot of each one. Please use Alt+PrtSc to take the shot, so that only the active window is included, not your whole desk top.
Yes! Sorry. Here you go (I'll update the main post, too.)
Help me.PNG
Please.PNG
@Kisa135 Here's a screenshot of a very simple door locked by key mechanism I used in a project:

Spoiler: Screenshot
2019-05-25.png

You could add a nested if statement in the else case of this one checking for Party has Key 2, create an else branch to that, and move the failure text to the second else branch from where it is. In each case of success, you can then simply create a switch which will tell you either Key1Used when ON or Key2Used when ON. Make sense? 🙂

EDIT: Thanks for including the screenshot update. What's the line of code Script: If Not: MisterSnugglesNo being used for? Is it a comment line? I thought you didn't want to use scripts. You should get rid of it either way. It may clear things up as an undefined script could do exactly what you're experiencing...crash the game.
@Kisa135 Here's a screenshot of a very simple door locked by key mechanism I used in a project:

Spoiler: Screenshot

You could add a nested if statement in the else case of this one checking for Party has Key 2, create an else branch to that, and move the failure text to the second else branch from where it is. In each case of success, you can then simply create a switch which will tell you either Key1Used when ON or Key2Used when ON. Make sense? 🙂

It does make sense, in fact it looks very similar to what I did in fact do but that didn't work so I tried a few other variations and I-
Well, I'm honestly kind of sad now. I'd love to get it working soon.
@Kisa135, try this plugin, so can || (or) statement to check if one of keys is there.

https://forums.rpgmakerweb.com/index.php?threads/conditional-branch.63723/

Try if it didn't help, you can tell me more lol.
@Kisa135, try this plugin, so can || (or) statement to check if one of keys is there.

https://forums.rpgmakerweb.com/index.php?threads/conditional-branch.63723/

Try if it didn't help, you can tell me more lol.
@Kupotepo That looks like it'll help a lot in streamlining the code but sadly my event still freezes at the end. 😢
It seems to be some issue with exiting out of the event (I could be wrong though)
@Kisa135 Did you see my EDIT above? Did you remove the Script line?
@Kisa135 Did you see my EDIT above? Did you remove the Script line?
@mathmaster74 Yes, I did while testing out the Conditional Choice+ plugin. It made no difference.
I added that line after testing without it and it did much the same thing.
@Kisa135 I think you completely misunderstood how the select item command works - because you can't use it like you did in your events.

First, when giving the select item command the player gets a window displaying all items of that type he has in inventory.
So there is absolutely no need to check if the player has an item - it will simply not appear in the list if he doesn't have it in his inventory as long as it fits the selection criteria.

Second, the variable specified in the command will get the ID of the item the player selects. You can't know in advance which item the player selects - that could be anything he has in the inventory.

So to check what the player has done you ALWAYS need a conditional branch checking that specific variable agains the possible IDs of the items that would work. You can't use that command without checking its result.

So you should always use the same variable in it - name it as "selection" or something like that.

Then your code would read
Select Item (variable #10 selection, key item)
Conditional branch if variable #10 = 5 (or ID of the Mister Snuggles item)
> switch mistersnuggles = ON
Conditional branch if variable #10 = 6 (or ID of the Mister Chicken Item)
> switch misterchicken = ON

and so on - you only need one select item command even if there are dozens of items that could be used, but you need one conditional branch with that variable for any item ID that should give a reaction (even if it is just a show text "this is sharp not fluffy" if the player selects a knive instead of the plush.


EDIT: And you get the crash because the script line "if not" is not a script, you can't use that there
@Kisa135 I think you completely misunderstood how the select item command works - because you can't use it like you did in your events...
@Andar Thank you very much for that explanation.
Unfortunately, even using it, my game doesn't do anything after putting the item in place.
I really don't understand.
The game runs perfectly fine, I get to the menus, I select the items alright, the image appears at the event location properly (Which tells me that the switches are working) But then as soon as the switch is down, I lose control of the player entirely.
The water in the scene still animates, I still have my follower, no part of the map glitches out... I just cannot move.
@Kisa135, sorry I do not understand. Please restate your sentence. Would you like to use the key to lock the door or open the door? So I can test to see myself.
@Kisa135, sorry I do not understand. Please restate your sentence. Would you like to use the key to lock the door or open the door? So I can test to see myself.
@Kupotepo Unlock.
Also, for some reason, adding an extra line of dialogue after the code makes it progress past the freeze...
Squinting really hard at my editor now because I DID try that before....

EDIT:
NEVERMIND, it only fixed itself for MisterChicken and not MisterSnuggles.
It still freezes up on that one even if I add extra dialogue.
You can do like @mathmaster74 way or you would like another way. Tested it worked.
Capture28.PNG
Capture29.PNG
You can do like @mathmaster74 way or you would like another way. Tested it worked. View attachment 116291 View attachment 116292
@Kupotepo I'm sure that works wonderful magic and I'm thankful for it but the key doesn't go into the door, the key is something placed onto a switch so the door becomes unlocked in another part of the same map.
@Kisa135, you make like a puzzle key which will open to another door far away. You have to give choices as Andar said sorry if you want to use items. Now the door will appear neither the key will open the door.
Capture30.PNG

Capture31.PNG
Capture32.PNG
Capture.PNG
This is my current code.
it works for MisterChicken. I just need it to also work for MisterSnuggles.
@Kisa135, I am sorry I completely forget about "Select Item Button."
I do not think it is something wronged with the first page. How about the second page and third page?
@Kupotepo Second and third pages are literally just:
"If this switch is active, say this"
I put the check for if the switch is active under the conditions bar on the left and unless that's also a coding mistake somehow...
@Kisa135
First rule:
ALWAYS, and that really means ALWAYS name a switch or variable as soon as it is used.
It has nothing to do with this error, but you will only cause yourself the greatest headaches if you forgot to name and then re-use some variables in your project.
In the case above you didn't name the variable #1 that you use to store the selection.

t works for MisterChicken. I just need it to also work for MisterSnuggles.
we need a better description than "doesn't work" to even start helping. WHAT does not work?
- Is the item not in the selection window of the command?
- can the item be selected but nothing happens?
- can the item be selected, the show text appears but the result in the game doesn't happen?

depending on what does and what does not happen there are different possible causes, and NONE of those causes are in the screenshot of the event. If you specify what happens and what not we can ask for other screenshots that will help find the cause.

Original thread: https://forums.rpgmakerweb.com/threads/a-door-with-many-keys.109385/