[Home] [Downloads] [Search] [Help/forum]

Locks examples

Below are some examples of using locks, to help you to formulate your own:

Lock something so no-one can take it


@lock mirror = #0

This just uses the "basic lock" to lock the mirror against database object #0 (the initial room). Since it is very unlikely that the player will be or carry that room, the lock always fails, thus the object cannot be taken.


Lock an exit so only female characters can pass


@lock north = sex:f*

This checks the attribute "sex" to be anything that starts with "f".


Lock an exit so only male or female characters can pass


@lock north = sex:m*|sex:f*

By using the "or" symbol ("|") you can check for one attribute or another.


Lock an exit so you must have a description to pass (useful for initial rooms)


@lock out = desc:*

This uses a "wildcard" character ("*") to ensure that the attribute "DESC" is not empty.


Lock an exit so you must have a description and gender of M or F to pass


@lock out = desc:*&(sex:m*|sex:f*)

This uses the "and" symbol ("&") in addition to the "or" symbol, as well as parentheses to group the "sex" check.


Lock something so only you can take it


@lock purse = me

This is useful for locking your possesions.


Lock an exit so you must be a wizard to pass through it


@lock south = Iswizard/1
&Iswizard south = [hasflag(%#, WIZARD)]

This uses an "evaluation lock" to evaluate an attribute "Iswizard". This attribute checks to see if the player attempting to pass the lock ("%#") has the flag "wizard". If so, it returns "1". This is then checked for in the lock.


Lock an exit so you must be a male wizard to pass through it


@lock south = Iswizard/1&sex:m*
&Iswizard south = [hasflag(%#, WIZARD)]

This uses the "and" operator to combine an evaluation lock with an attribute lock.


Lock yourself so you cannot be taken


@lock me = me

Without this lock, other players can pick you up and take you places.


Lock yourself so you cannot be paged by someone


@lock/page me = !*Bozo

This prevents player Bozo from paging you.

You can lock yourself against all pages by using:

@lock/page me = #0

Another method of avoiding all pages is to set the "haven" flag on yourself, ie.

@set me = haven

Lock a room so some players cannot speak in it


@lock/speech here = !*Bozo

This prevents player Bozo from speaking in this room. Note that this lock does not affect wizards.


Lock an exit so you must be carrying something to pass through it


@lock west = +key

Players must be carrying "key" to go west.


Lock all exits against the same thing


@lock north = desc:*&(sex:m*|sex:f*)
@lock south = @north
@lock east = @north
@lock west = @north

By using an "indirect lock" (indicated by the "@" character) you only need to type in a complex lock once, and then lock other things "indirectly" against that lock.

This not only saves you typing the lock over and over again, but makes it easier to change the lock. If you need to change the lock, you only need to change it once.


[Previous] [Next] [Back] [Home]
Written by Nick Gammon - 5K

Comments to Gammon Software support

[Best viewed with any browser - 2K]    Internet Contents Rating Association (ICRA) - 2K    [Web site powered by FutureQuest.Net]

Page updated on Wednesday, 15 December 2004