LSL Protocol/Restrained Life Relay/Mouselook
Put this script into a small child prim of the relay. It will resize this prim to full size if the victim does not stay in mouselook while urged to do so.
Note: @thirdview=n is an inoffical command. It has never been part of the specification and might be replaced by a meta command.
Code
<lsl> // Code by Maike Short based on an inoffical protocol extension by Monica Jewell
integer RLV_LINK_CHANNEL = -1373421301;
integer mouselook = FALSE; // should the sub be in mouselook? integer mouselookTicks = 0; // count the timer ticks until the next reminder message is printed again integer mouselookLast = TRUE; // was the sub in mouselook during last check?
// punish the sub punish() {
// ensure that we are attached to the HUD
// we don't want a 10x10x10 black prim in world
integer point = llGetAttached();
if ((point < ATTACH_HUD_CENTER_2) || (point > ATTACH_HUD_BOTTOM_RIGHT))
{
return;
}
llSetPrimitiveParams([PRIM_SIZE, <10, 10, 10>]);
llSetAlpha(1, ALL_SIDES);
llOwnerSay("@edit=n");
}
// undo the punishment release() {
llSetPrimitiveParams([PRIM_SIZE, <0, 0, 0>]);
llSetAlpha(0, ALL_SIDES);
llOwnerSay("@edit=y");
}
// enforce mouselook handleMouselook() {
// first of all check that mouselook is enforced
if (!mouselook)
{
llSetTimerEvent(0);
mouselookTicks = 0;
release();
return;
}
// good, now check that the avatar is in mouselook
integer data = llGetAgentInfo(llGetOwner());
integer mouselookIn = (data & AGENT_MOUSELOOK);
if (!mouselookIn)
{
if (mouselookTicks % 60 == 0)
{
llOwnerSay("Go to mouselook or stay blind.");
}
mouselookTicks++;
}
// if we are still in mouselook, or if we are still not in mouselook,
// the HUD will still be in the correct state
if (mouselookIn == mouselookLast)
{
// no need to mess with the prim
return;
}
// something has changed, either punish or lift the punishment
if (mouselookIn)
{
release();
}
else
{
punish();
}
// remember whether we punished or lifted the punisment mouselookLast = mouselookIn;
}
default {
state_entry()
{
release();
}
on_rez(integer i)
{
if (mouselook)
{
llOwnerSay("Go to mouselook or stay blind");
}
// get mouselook code into correct state
mouselookLast = TRUE;
handleMouselook();
}
// handle commands
link_message(integer sender, integer channel, string message, key id)
{
if (channel != RLV_LINK_CHANNEL)
{
return;
}
if ((message == "@thirdview=y") || (message == "@clear"))
{
// lift mouselook enforcement
llSetTimerEvent(0);
mouselook = FALSE;
release();
}
else if (message == "@thirdview=n")
{
// start mouselook enforcement
mouselook = TRUE;
mouselookLast = TRUE;
handleMouselook();
llSetTimerEvent(1);
}
}
// check if the sub obeys while mouselook is enforced
timer()
{
handleMouselook();
}
// we don't want a nasty surprise for the next owner
changed(integer change)
{
if (change & CHANGED_OWNER)
{
llResetScript();
}
}
} </lsl>