I'm not sure how to make it so that a player can unlock a door (if they have the key). I have created the key object and the door exit, just not sure how to make them connect.
For option 2, there are other things you could do like run scripts instead of automatically doing things. All the player has to do with this door is type 'unlock door' and if the player has the key, it will automatically do the rest.
Let me know if this helps.
Below is the code I used if you want to copy-paste it and take a look.
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Locking and Unlocking Test">
<gameid>c3e0e639-ed0d-42a2-92c4-39acd2ceca0a</gameid>
<version>1.0</version>
<firstpublished>2017</firstpublished>
</game>
<object name="room1">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit name="doorlock1" alias="south" to="room2">
<inherit name="southdirection" />
<locked />
</exit>
<object name="door">
<inherit name="editor_object" />
<look type="script">
if (GetBoolean(door, "unlock1")) {
msg ("The door has been unlocked and you can go south.")
}
else {
msg ("The door is locked and blocks your path.")
}
</look>
</object>
<object name="key">
<inherit name="editor_object" />
<look>It's a key and can be used to unlock doors.</look>
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="door">
if (GetBoolean(door, "unlock1")) {
msg ("The door is already unlocked.")
}
else {
msg ("You use the key to unlock the door.")
SetObjectFlagOn (door, "unlock1")
UnlockExit (doorlock1)
}
</item>
</selfuseon>
<take />
</object>
</object>
<object name="room2">
<inherit name="editor_room" />
<exit alias="north" to="room1">
<inherit name="northdirection" />
</exit>
<object name="door1">
<inherit name="editor_object" />
<look type="script">
if (GetBoolean(door, "unlock1")) {
msg ("The door has been unlocked and you can go north.")
}
else {
msg ("The door is locked and blocks your path.")
}
</look>
<alias>door</alias>
</object>
<exit alias="south" to="room3">
<inherit name="southdirection" />
</exit>
</object>
<object name="room3">
<inherit name="editor_room" />
<exit name="doorlock2" alias="south" to="room4">
<inherit name="southdirection" />
<locked />
</exit>
<object name="key2">
<inherit name="editor_object" />
<alias>gold key</alias>
<look>It's a key.</look>
<take />
</object>
<object name="door2">
<inherit name="editor_object" />
<inherit name="container_lockable" />
<inherit name="container_closed" />
<alias>door</alias>
<look type="script">
if (door2.isopen) {
msg ("The door is open and you can travel south if you wish.")
}
else {
msg ("The door is locked it appears.")
}
</look>
<feature_container />
<keycount type="int">1</keycount>
<key type="object">key2</key>
<onunlock type="script">
UnlockExit (doorlock2)
</onunlock>
<open />
<close />
</object>
</object>
<object name="room4">
<inherit name="editor_room" />
</object>
</asl>