Difference between revisions of "LSL Protocol/Restrained Life Relay/How to Test/Relay Test 03"

From Second Life Wiki
Jump to navigation Jump to search
(New page: == Objection == Ensure that pending restrictions in ask mode are correctly lifted if they world object releases control before the permission dialog is accepted. == Instructions == # Pa...)
 
m (Wiki Syntax)
Line 5: Line 5:
== Instructions ==
== Instructions ==


# Part 1: One line restriction release
Part 1: One line restriction release
## Set relay to ask mode. Note: Some relays don't ask again if the object is owned by the same person who owned the last object
# Set relay to ask mode. Note: Some relays don't ask again if the object is owned by the same person who owned the last object
## Touch box  
# Touch box  
## Accept permission
# Accept permission
## Say "hello"
# Say "hello"


# Part 2: Two line restriction release
Part 2: Two line restriction release
## Box asks you to not accept permission yet
# Box asks you to not accept permission yet
## Box asks you to accept permission dialog
# Box asks you to accept permission dialog
## Say "hello"
# Say "hello"


== Known Problems in the Test ==
== Known Problems in the Test ==

Revision as of 16:28, 28 February 2009

Objection

Ensure that pending restrictions in ask mode are correctly lifted if they world object releases control before the permission dialog is accepted.

Instructions

Part 1: One line restriction release

  1. Set relay to ask mode. Note: Some relays don't ask again if the object is owned by the same person who owned the last object
  2. Touch box
  3. Accept permission
  4. Say "hello"

Part 2: Two line restriction release

  1. Box asks you to not accept permission yet
  2. Box asks you to accept permission dialog
  3. Say "hello"

Known Problems in the Test

  • Some Relays don't display both permission dialogs because they implicitly trust other objects by the same owner as the last used object.

Code

Root Prim

<lsl> integer CHANNEL_RELAY = -1812221819; // Relay Channel integer CHANNEL_PUBLIC = 0;

integer STEP_START = 0; integer STEP_WAIT_FOR_HELLO = 1; integer STEP_SECOND_TEST = 2; integer STEP_WAIT_FOR_SECOND_HELLO = 3; integer STEP_DONE = 4;

integer step = STEP_START;


// looks for the confirmation of the sendchat restriction handleRelayResponse(string message) {

   list tokens = llParseString2List(message, [","], []);
   string question = llList2String(tokens, 2);
   string response = llList2String(tokens, 3);
   if (question == "@sendchat=n")
   {
   	if (response == "")
   	{
   		return;
   	}
       if (response != "ok")
       {
           llSay(0, "FAIL: Relay did reject @sendchat command");
           return;
       }
       llSay(0, "Please say \"hello\" on public chat.");
       if (step == STEP_START)
       {
           step = STEP_WAIT_FOR_HELLO;
       } else if (step == STEP_SECOND_TEST)
       {
           step = STEP_WAIT_FOR_SECOND_HELLO;
       } 
   }

}


// handles avatar chat handleAvatarResponse(string message) {

   if (message == "...")
   {
       llSay(0, "FAIL: @sendchat restriction should already be lifted.");
   }
   else if (llToLower(message) == "hello")
   {
       if (step == STEP_WAIT_FOR_HELLO)
       {
           llSay(0, "PASS: one line ask mode test");

llMessageLinked(LINK_SET, 1, "send_restrictions", NULL_KEY);

           step = STEP_SECOND_TEST;
           llSetTimerEvent(10); 
       }
       else if (step == STEP_WAIT_FOR_SECOND_HELLO)
       {
           llSay(0, "PASS: two line ask mode test.");
           step = STEP_DONE;
       }
   }
   

}

default {

   state_entry()
   {
       llListen(CHANNEL_RELAY, "", "", "");
       llListen(CHANNEL_PUBLIC, "", "", "");
   }
   on_rez(integer ignored)
   {
       llSetText(llGetObjectName(), <1, 1, 1>, 1);
       llSay(0, "Set your relay to ask mode and touch me.");
   }
   listen(integer channel, string name, key id, string message)
   {
       if ((llGetOwnerKey(id) == id) && (channel == CHANNEL_PUBLIC))
       {
           handleAvatarResponse(message);
       }
       if ((llGetOwnerKey(id) == llGetOwner()) && (channel == CHANNEL_RELAY))
       {
           handleRelayResponse(message);
       }
       llOwnerSay(name + ": " + message);
   }
   
   touch_start(integer ignored)
   {
       if (llDetectedKey(0) != llGetOwner())
       {
           llSay(0, "Hey, " + llDetectedName(0) + " don't mess with me!");
           return;
       }
       
       step = STEP_START;
       llSay(CHANNEL_RELAY, "relaytest," + (string) llGetOwner() + ",@sendchat=n|!release"); 
       llSay(0, "Please accept permission.");
   }
   timer()
   {
       llSay(0, "Please accept the permission dialog now. If you did not get a second one, the first test failed.");
       llSetTimerEvent(0); 
   }

} </lsl>

Child Prim

<lsl> integer CHANNEL_RELAY = -1812221819; // Relay Channel

default {

   link_message(integer sender, integer channel, string message, key id)
   {

llSay(0, "Please do not press a button in the permission dialog, yet");

       llSay(CHANNEL_RELAY, "relaytest," + (string) llGetOwner() + ",@sendchat=n"); 
       llSay(CHANNEL_RELAY, "relaytest," + (string) llGetOwner() + ",!release");
   }

} </lsl>