SetDoorKey
Makes one of your tagged items the key of a door - its holder unlocks the door the game’s own way.
id is a tagged item’s id (GivePlayerTaggedItem: "house-12-key"). A player who holds that item in the bag gets the game’s
own “Unlock and open” on the locked door, from the side its lock opens from with a key (both sides with SetDoorLockSides
"both"), and the use unlocks and opens it - OnPlayerUseDoor hears it as any use. The level’s own key of the door still works.
The item is the key wherever it is: dropped, in a chest or sold, it opens nothing for the one who no longer holds it. A copy is
another tagged item with the same id in another player’s bag. nil or "" takes the key away. At most 4096 doors.
With world the key is that virtual world’s alone (SetPlayerVirtualWorld - a flat’s copy of a house): for the players there it
takes the place of the key every world shares (set without world), which still opens the door in every other world. nil or ""
with a world takes that world’s key away, and the shared key is the door’s key there again.
Syntax
Section titled “Syntax”SetDoorKey(door, id [, world])| Parameter | Type | |
|---|---|---|
door |
string | the door’s level name |
id |
string | nil | the tagged item’s id; nil = none |
world |
number | a virtual world whose own key this is; none (the default) = the key of every world (optional) |
Returns
Section titled “Returns”boolean - false for an empty or too long key or id, "*", or past 4096 doors (each world’s own keys: 4096 doors too)
Example
Section titled “Example”-- a house bought: its door and its chest open with the deed holder's keyGivePlayerTaggedItem(pid, "key_home", "house-12-key", "Key to the mill house", "Opens the mill house and its chest.")SetDoorKey(MILL_DOOR, "house-12-key")SetContainerKey(MILL_CHEST, "house-12-key")-- each flat's copy of the house: its own key for the same doorSetDoorKey(FLAT_DOOR, "flat-3-key", flat3.world)See also
Section titled “See also”GetDoorKey · SetContainerKey · SetDoorLockSides · GivePlayerTaggedItem · FindPlayerItem · SetVirtualWorldOwnDoors · the Doors and containers group of the index
