Using Keys [Solved]

DavyB
22 Apr 2018, 09:45Hopefully something simple for a change...
If I have a door implemented as a locked container, I typically assume the player with a key would use "unlock door". How can I arrange for "use key" and "use key with door" to achieve the same effect?
I know I can use HandleCommand ("unlock door", null) in a script but the resulting output might confuse the player.
hegemonkhan
22 Apr 2018, 16:41the locked/unlocked state is controlled by the 'NAME_OF_OBJECT_OR_EXIT.locked' (locked) Boolean Attribute:
locked state: NAME_OF_OBJECT_OR_EXIT.locked = true
unlocked state: NAME_OF_OBJECT_OR_EXIT.locked = false
whereas, for the opened/closed state, it's the 'NAME_OF_OBJECT_OR_EXIT.isopen' (isopen) Boolean Attribute:
opened state: NAME_OF_OBJECT_OR_EXIT.isopen = true
closed state: NAME_OF_OBJECT_OR_EXIT.isopen = false

K.V.
22 Apr 2018, 17:29Hello, DavyB!
Here's a small example game which should help you out:
<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Keyses">
<gameid>7b8e2bfc-8ece-4d1b-a828-2ae54e27d7c6</gameid>
<version>2.0</version>
<firstpublished>2018</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="door">
<inherit name="editor_object" />
<inherit name="openable" />
<inherit name="container_lockable" />
<feature_container />
<keycount type="int">1</keycount>
<key type="object">Skellington Key</key>
<autoopen />
<autounlock />
<look>It is {either door.isopen:open|closed} and {either door.locked:locked|unlocked}.</look>
<displayverbs type="stringlist">
<value>Look at</value>
<value>Open</value>
<value>Close</value>
<value>Unlock</value>
<value>Lock</value>
</displayverbs>
</object>
<object name="Skellington Key">
<inherit name="editor_object" />
<take />
<look>It's just an average key.</look>
<feature_usegive />
<use />
<selfuseon type="scriptdictionary">
<item key="door">
do (door, "unlock")
</item>
</selfuseon>
</object>
</object>
</asl>

DavyB
22 Apr 2018, 20:15Thanks KV. What that boils down to is providing
do (door, "unlock")
as the script action for "use key with door", which is what I was hoping to find, ...and it works!
More code would be needed to achieve the same effect with "use key" (making sure the door is within scope and dealing with the error case) but I decided to simply respond "How do you want to use the key?"

K.V.
22 Apr 2018, 22:05With the set up in that example game, USE KEY will provide a menu of all reachable objects: