Noob question: Need multiple items to unlock door

abcdefghq11
02 Aug 2012, 21:54
I'm making a detective game where in one part you have to collect multiple items. How do I do this?
Scott :mrgreen:
p.s A sample would be preferable

Pertex
03 Aug 2012, 05:52
What does "multiple objects" mean?

sgreig
03 Aug 2012, 11:31
Yeah, you're going to have to be more specific as to what you mean, because Quest already has the ability for the player to pick up multiple items.

abcdefghq11
04 Aug 2012, 05:36
sorry i messed up. I mean how do I pick up multiple items to unlock an exit?

sgreig
04 Aug 2012, 05:56
So if I understand correctly, you want to have a locked exit that required the player to have several objects to open? There's two ways I can think of to do it. Both methods involve using nested IF statements.

1. Have the game check if each of the objects is present in the player's inventory. This is probably the most straightforward way.

2. Have the game set a flag, such as "player.hasobjectX" each time one of the required items is picked up, then use the nested IF statements to check if all of the flags are true.

The code would in both cases would look similar to this:



if (check for condition) {
if (check for second condition) {
if (check for third condition) {
[code to unlock the exit]
}
}
}


That's obviously not the proper syntax, but hopefully you get the idea.