A specific named item in inventory unlocks a specific named obstacle in a one-to-one correspondence; item is consumed.
A keyed lock is one-to-one: the red key is rejected by the blue door and opens only the matching red door — specific, not a master key.
A one-to-one consumable gate: a named item opens a named obstacle, and using it destroys the item. It's flag gating tied to inventory.
The lock checks inventory for the matching key by id. Ownership is the gate; nothing about the door is hardcoded except the id it wants.
func try_open(door):
if not inventory.has(door.key_id): return falseOn success, consume the key and set the door's open flag — the same set_flag pattern as any other progression gate.
inventory.erase(door.key_id)
flags[door.id + "_open"] = true
return trueThe physical door. When its open flag is set, disable the collider (or play the open animation) so the path becomes passable.
func _on_flag(name, val):
if name == id + "_open": $Block.set_deferred("disabled", true)In short: Interaction checks has_item('iron_key'); on success: remove_item('iron_key') and set_flag('door_open', true)
37 catalogued game(s) use this mechanic, spanning 1986–1997.
▶ Explore Key Lock interactively — see every game + the Godot system