Difference between revisions of "A lock with TWO keys"

From ADRIFT 5 Manual Wiki
Jump to: navigation, search
(Created page with "ADRIFT allows you to easily select which dynamic object is used as the key to unlock a particular door or cabinet, but if you want the player to be able to use either of two keys...")
 
(Lock objects with key)
Line 19: Line 19:
 
== Lock objects with key ==
 
== Lock objects with key ==
 
Open the "Lock objects with key" task in the "Open and Close" folder, and switch to the restrictions page.
 
Open the "Lock objects with key" task in the "Open and Close" folder, and switch to the restrictions page.
The last restriction here is
+
 
 +
The last restriction here is  
 +
Property 'Key for lock' for Referenced Object 1 must be 'Referenced Object 2'
 +
We need to add a new restriction that checks our new property:
 +
 
 +
[[File:RestrictionSecondKey.jpg]]
 +
 
 +
But we want this task to pass if EITHER key is visible to the player, so click on the AND between them to change it to an OR, and click on the vertical grey bars tp put parentheses around those two restrictions, as shown here:
 +
 
 +
[[File:RestrictionsOR.jpg]]
 +
 
 +
That fixes the locking, but we still need to do the unlocking. Do the above for the "Unlock objects with key" task as well.
 +
 
 +
== Lock Objects (Lazy) ==
 +
If the player types "Lock door" without mentioning the key, the "Lock Objects (Lazy)" will check if they are holding the correct key by executing the "Lock objects key check" task, which then executes the "Lock objects with key" task using that key.
 +
 
 +
To do this with two different keys, and still give all of the correct responses when the player doesn't have either key, we will need a silent version of the key check task, and two specific tasks which override the Lock Objects (Lazy) task.
  
 
== Silent key check ==
 
== Silent key check ==

Revision as of 07:33, 22 June 2013

ADRIFT allows you to easily select which dynamic object is used as the key to unlock a particular door or cabinet, but if you want the player to be able to use either of two keys to unlock the door, then we need to create a new object property for it and add support for it to all of the lock/unlock commands.

Second key property

We know this is going to be similar to the existing "Key for lock" property in the Standard Library, so open the "Open and Close" folder and right click on "Key for lock":

CopyKeyForLock.jpg

Select "Copy" from the menu.

Right click on the folder you want to copy it to and select "Paste"

Now double-click the new property to open it. The first thing we want to do is change the name to "Second key for lock", then remove the tick from the "Mandatory" box as we still want to be able to have other locks with only one key. Click OK to save it.

SecondKeyForLock.jpg

If you open any lockable object you will now see the new property directly under the "Key for lock" property, and if you tick it you can then select a dynamic object as its second key.

Lock objects with key

Open the "Lock objects with key" task in the "Open and Close" folder, and switch to the restrictions page.

The last restriction here is

Property 'Key for lock' for Referenced Object 1 must be 'Referenced Object 2'

We need to add a new restriction that checks our new property:

RestrictionSecondKey.jpg

But we want this task to pass if EITHER key is visible to the player, so click on the AND between them to change it to an OR, and click on the vertical grey bars tp put parentheses around those two restrictions, as shown here:

RestrictionsOR.jpg

That fixes the locking, but we still need to do the unlocking. Do the above for the "Unlock objects with key" task as well.

Lock Objects (Lazy)

If the player types "Lock door" without mentioning the key, the "Lock Objects (Lazy)" will check if they are holding the correct key by executing the "Lock objects key check" task, which then executes the "Lock objects with key" task using that key.

To do this with two different keys, and still give all of the correct responses when the player doesn't have either key, we will need a silent version of the key check task, and two specific tasks which override the Lock Objects (Lazy) task.

Silent key check

, then use the same method to make a copy of 1. Make a copy of "Lock objects key check" and call it "Lock objects silent key check" 2. Open its only restriction and delete the text "What do you want to lock %object1%.Name with?" in its message box (make sure you delete every last space and carriage return) 3. In the restrictions of "Lock objects with key" where we added the check for the second key, make sure its text box contains the same text as the restriction for the 'key for lock' above it. 4. Delete both actions in "Lock Objects (Lazy)" 5. Create two SPECIFIC tasks which override "Lock Objects (Lazy)", call them something like "Lock with first key" and "Lock with second key" 6. Add action: Execute task [Lock objects key check] with parameters "%object1%" and "%object1%.LockKey" to "Lock with first key". 7. Add action: Execute task [Lock objects silent key check] with parameters "%object1%" and "%object1%.Property15" to "Lock with second key". 8. Only to "Lock with second key", add a restriction [Referenced object][must][have property][Second key for lock] 9. Make sure "Lock with second key" has a higher priority (smaller number) than "Lock with first key". 10. In "Unlock objects key check" is an action to execute task "Unlock objects with key". Change its second parameter to "%Object2%". 11. Repeat steps 1 to 9 for the Unlock tasks.


the 'Lock/Unlock objects with key' tasks should have a higher priority (lower number) than the 'Lock/Unlock Object (Lazy)' tasks.


<<< Conversations with other charactersMain PageClothing Slots >>>