June 19, 2012

A deed-once land media manager

Consider this script fragment:

integer mediaChannel = -8782764;
key authorizedUser = "817b2981-aeb6-42db-9478-1d525624c66e";

default
{
 
state_entry() {
  llListen( mediaChannel, "", NULL_KEY, "" );
}

listen( integer channel, string fromName, key fromKey, string msg) {
  if ( (channel == mediaChannel)
              && (llGetOwnerKey(fromKey)==(key)authorizedUser) ) {

    list a = llParseStringKeepNulls(msg,["|"], [] );
    string verb = llList2String(a,0);
    integer match = llListFindList(["setMedia", "queryMedia"],[verb]);
    if ( match >= 0 ) {
      string tag = llList2String(a,1);
      integer n = (integer)llList2String(a,2);
      if ( n > 0 ) {
        list b = decodeList( llList2List(a,3,2+n) );
        if ( match == 0 ) {
           llParcelMediaCommandList( b );
           llRegionSayTo(fromKey, mediaChannel, llDumpList2String(
                      [ verb+"Ack", tag, "ok" ], "|"));
        } else if ( match == 1 ) {
           list c = encodeList ( llParcelMediaQuery(b) );
           llRegionSayTo(fromKey, mediaChannel, llDumpList2String(
                      [ verb+"Ack", tag, "ok",
                          llGetListLength(c)] + c, "|"));
        }
      } else {
         llRegionSayTo(fromKey, mediaChannel, llDumpList2String(
                 [ verb+"Ack", tag, "fail", "no list" ], "|"));
      }
    }
  }
}

}

If you add the encode/decode functions, place the script into a prim and then have that prim deeded to a parcel, then undeeded scripted objects that are owned by the authorizedUser and that send messages on the mediaChannel will be able to manage land media.

If you are a land manager that hosts exhibits, then you can use this script to give your visiting exhibitors control of the land media without giving them the power to deed objects to the land.

____________________________
Notes:
  • The encodeList() and decodeList() functions are described in the prior post "Interobject Communications: lists".
  • Sending media commands and query reults as encoded lists in messages means that you will never have to add features to this script.  If Linden Labs one day supports a new media action (PARCEL_MEDIA_COMMAND_whatever) then this script will already support that action.
  • The verb 'deed' it is shorthand for the longer, more awkward phrase "deed to a group that owns the parcel or have the parcel owner rez on the parcel".