(12-23-2010, 12:07 PM)sixsevensix Wrote: I have run into trouble, I have made a puzzle that requires the player to go through and try different keys on a door to open it, one of the six keys are correct (this part works) and unlocks the door, the other 5 are wrong and need to be discarded, the problem I am having is creating a function general enough to work for any key that is NOT the key to the door. Is there a way to go about this without using an add item callback for each key?
Code:
////////////////////////////
// wrongkey function
void WrongOne(string &in asItem, string &in asEntity)
{
if(asItem!="LanternKey"){
PlaySoundAtEntity("", "lock_door.snt", "LanternDoor", 0.0f, false);
RemoveItem(asItem);
}
}
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Wrong1", "LanternDoor", "WrongOne", false);
}
///////////
I just recently started scripting but I'm pretty sure you could name the 5 wrong keys Wrong_1, Wrong_2, etc and in the AddUseItemCallback for the entity put "Wrong_*" As for discarding the keys just don't remove item until the correct key is used then in that function run RemoveItem("Wrong_*); and RemoveItem("Right").
That should work in giving you just one general function for the wrong keys instead of 5.