Skip to content

SetContainerKey

Makes one of your tagged items the key of a chest - its holder unlocks the chest the game’s own way.

As SetDoorKey for a chest (its key as GetContainers and GetNearestContainer name it): a player who holds the tagged item with that id in the bag gets the game’s own “Unlock and open” on the locked chest, and the use unlocks it - OnPlayerUnlockContainer hears it like any unlock - then opens it. The level’s own key still works. nil or "" takes the key away. At most 512 chests.

SetContainerKey(key, id)
Parameter Type
key string the chest’s key
id string | nil the tagged item’s id; nil = none

boolean - false for an empty or too long key or id, "*", or past 512 chests

SetContainerLocked(MILL_CHEST, true)
SetContainerKey(MILL_CHEST, "house-12-key")

GetContainerKey · SetDoorKey · SetContainerLocked · OnPlayerUnlockContainer · the Doors and containers group of the index