Locks
Introduction
Locks are a very important part of MUSH building - they help give the world its "flavour", by enforcing rules and conditions.
Basically you could define a lock thus:
- A locked object cannot be used unless the thing attempting to use it passes the lock
Examples of locks
- A locked exit prevents players from passing through it. eg.
@lock east = sex:m*This only allows "male" character to use the "east" exit.
- A locked player or object cannot be taken (picked up). eg,
@lock mirror = #0This prevents anyone from taking the mirror.
- A locked room can display a different description than when it is unlocked.
@lock here = Iswizard/1 &Iswizard here = [hasflag(%#, WIZARD)] @succ here = You notice a secret exit behind the fireplace.This would show a description about a secret exit to wizards only.
Success and failure messages
You should generally set a "success" and "failure" message on any object which is locked, so that the player attempting to pass the lock sees an explanatory message. For example:
@lock east = +key
@succ east = You unlock the door and go through it.
@fail east = You must be carrying the key to go through this door.
You should also set "other success" and "other failure" messages on a locked object, so that others in the same room see what is happening to the player.
@osucc east = unlocks the door and passes through.
@ofail east = tugs uselessly at the door.
These messages are covered in more detail in a subsequent page.
Click on Lock Messages for more details about messages that are triggered by attempting to use locked objects.
@LOCK syntax
@lock[/<switch>] <object>=<key>
Locks <object> to a specific key(s). <object> can be specified as <name>
or #<number>, or as 'me' or 'here'. Boolean expressions are allowed, using
'&' (and), '|' (or), '!' (not), and parentheses ('(' and ')') for grouping.
To lock to a player, prefix their name with '*' (ex. '*Moonchilde').
Example:
@lock Purse = me|*Darling
will lock object purse so that only you or player Darling can take it.
There are further topics on locks: