Home
About
Policies
FAQ
Forums
Registration
Password Recovery

Privacy room lock

From Tapestries MUCK

(Difference between revisions)
Jump to: navigation, search
 
(4 intermediate revisions not shown)
Line 1: Line 1:
-
This set of [[MPI]] statements will help you set up privacy locks on rooms in your area. It can be used in a single [[room]], or you can [[link]] the [[action]] to your [[parent room]] to save [[quota]] and have the lock command work in all child rooms.
+
This set of [[MPI]] statements will help you set up privacy locks on rooms in your area. It can be used in a single [[room]], or you can [[link]] the [[action]] to your [[Parent Room]] to save [[quota]] and have the lock command work in all child rooms.
The idea is to have a command that a player inside of a room can use to lock the room so that no one else can enter until it is unlocked or everyone leaves. Note that the code in this example assumes you have only one [[exit]] which leads to the room in question.
The idea is to have a command that a player inside of a room can use to lock the room so that no one else can enter until it is unlocked or everyone leaves. Note that the code in this example assumes you have only one [[exit]] which leads to the room in question.
Line 29: Line 29:
Now, since we can expect room users to lock the room, have their fun, and then leave without unlocking it, a little cleanup is needed. The easiest way to do this is to make a successful use of the exit reset the roomlock property on the room to 0. This is safe because if entry is allowed, it means the room either wasn't locked to begin with, or there is no one in it. You may already have text in the exit's [[@succ]] property. Just append the MPI to the end, like this (again substituting your room's actual dbref for #123456):
Now, since we can expect room users to lock the room, have their fun, and then leave without unlocking it, a little cleanup is needed. The easiest way to do this is to make a successful use of the exit reset the roomlock property on the room to 0. This is safe because if entry is allowed, it means the room either wasn't locked to begin with, or there is no one in it. You may already have text in the exit's [[@succ]] property. Just append the MPI to the end, like this (again substituting your room's actual dbref for #123456):
-
@succ exit=(Existing exit succ text) {null:{store:0,roomlock,#123456}}
+
<mpi>@succ exit=(Existing exit succ text) {null:{store:0,roomlock,#123456}}</mpi>
 +
 
 +
==Credit==
 +
Code provided by [[User:Harwich|Harwich]].
[[Category:Publicly Usable MPI]]
[[Category:Publicly Usable MPI]]

Latest revision as of 03:03, 30 April 2007

This set of MPI statements will help you set up privacy locks on rooms in your area. It can be used in a single room, or you can link the action to your Parent Room to save quota and have the lock command work in all child rooms.

The idea is to have a command that a player inside of a room can use to lock the room so that no one else can enter until it is unlocked or everyone leaves. Note that the code in this example assumes you have only one exit which leads to the room in question.

First, the action. go to the room you want to be able to lock (or your parent room), and create it:

@action lock;unlock=here

Next, link it to the gen-nothing MUF program (which just makes it silent so you can control its output):

@link lock=#45

Next, give it some functionality:

@succ lock={null:{if:{smatch:{&cmd},unlock},{store:0,roomlock,{loc:me}}{otell:{name:me} unlocks the door.,{loc:me},#-1},{store:1,roomlock,{loc:me}}{otell:{name:me} locks the door.,{loc:me},#-1}}}

This MPI stores 0 in a property on the room called "roomlock" if the player typed "unlock" and 1 if they typed "lock". It also echoes a bit of text to everyone in the room to give some feedback. The following code will then use this flag to control access to the room.

On the exit which leads to the room (which is called "exit" for this example), create a property called "locktest" containing a logical MPI expression, like so (Be sure to replace #123456 with the actual dbref of the destination room):

@set exit=locktest:{and:{lmember:{parse:thing,{contents:#123456},{awake:{&thing}}},1},{prop:roomlock,#123456}}

When evaluated, this MPI returns 1 (TRUE) *ONLY* when the roomlock property on the destination room is 1, *AND* there is an awake player in the room. Therefore, whenever this expression evaluates to 0 (FALSE), which means the room is either unlocked or empty or both, entry should be allowed.

To use this logical test, put it in the @lock property of the exit, like so:

@lock exit=locktest:0

Now, since we can expect room users to lock the room, have their fun, and then leave without unlocking it, a little cleanup is needed. The easiest way to do this is to make a successful use of the exit reset the roomlock property on the room to 0. This is safe because if entry is allowed, it means the room either wasn't locked to begin with, or there is no one in it. You may already have text in the exit's @succ property. Just append the MPI to the end, like this (again substituting your room's actual dbref for #123456):

@succ exit=(Existing exit succ text) {null:{store:0,roomlock,#123456}}

Credit

Code provided by Harwich.

Personal tools
Namespaces
Variants
Actions
navagation
information
wiki
Toolbox