About

This code is for creating a door that pushes away avatars once they collide with it unless they are in the access list. It uses the primitive text storage to permanently store avatar keys.

Code

///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
// Add or delete keys from this list to set administrators.
list ADMIN = [ "dd431fd0-f7c8-4cdb-9472-b6cf3a9f5f4e", "b978d7e3-b8c4-436c-aa95-a6066449862d" ];
 
string q = "";
 
default {
    state_entry() {
        integer i = llGetListLength(ADMIN)-1;
        do {
            llListen(1, "", llList2Key(ADMIN, i), "");
        } while(--i>-1);
    }
 
    listen(integer channel, string name, key id, string message) {
        list data = llParseString2List(message, [" "], []);
        list store = llCSV2List(llList2String(llGetPrimitiveParams([PRIM_TEXT]), 0));
        if (llList2String(data, 0) != "delete") jump show;
        q = "delete";
        llHTTPRequest("http://www.w3.org/services/html2txt?url=" + llEscapeURL("http://vwrsearch.secondlife.com/client_search.php?session=00000000-0000-0000-0000-000000000000&q=") + llEscapeURL(llList2String(data, 1) + " " + llList2String(data, 2)), [], "");
@show;
        if (llList2String(data, 0) != "show") jump flush;
        llSay(0, "------------- ACCESS LIST ------------");
        do {
            key a = llList2Key(store, 0);
            store = llDeleteSubList(store, 0, 0);
            llRequestAgentData(a, DATA_NAME);
        } while(llGetListLength(store));
        // alarm 1
        llSetTimerEvent(1);
        return;
@flush;
        if (llList2String(data, 0) != "flush") jump add;
        llSetText("", <0,0,0>, .0);
        llSay(0, "Access list has been flushed.");
        return;
@add;
        if (llList2String(data, 0) != "add") return;
        key aKey = llList2Key(data, 1);
        if (aKey) {
            jump gotkey;
        }
        q = "add";
        // We possibly have a name, resolve the name to a key.
        llHTTPRequest("http://www.w3.org/services/html2txt?url=" + llEscapeURL("http://vwrsearch.secondlife.com/client_search.php?session=00000000-0000-0000-0000-000000000000&q=") + llEscapeURL(llList2String(data, 1) + " " + llList2String(data, 2)), [], "");
        return;
@gotkey;
        // We have a key.
        store = llCSV2List(llList2String(llGetPrimitiveParams([PRIM_TEXT]), 0));
        if (llListFindList(store, (list) aKey) != -1) return;
        store += aKey;
        llSetPrimitiveParams([PRIM_TEXT, llList2CSV(store), < 0, 0, 0 > , .0]);
    }
    dataserver(key queryid, string data) {
        // alarm 1
        llSetTimerEvent(1);
        llSay(0, data);
    }
    timer() {
        llSetTimerEvent(0);
        llSay(0, "-------------------------------------------");
    }
    http_response(key request_id, integer status, list metadata, string body) {
        if (status != 200) return;
        key aKey = llList2Key(llParseString2List(body, ["secondlife:///app/agent/", "/about"], []), 1);
        if(aKey) {
            jump gotkey;
        }
        // got bad key, complain.
        llSay(0, "Sorry, that name could not be found.");
        return;
@gotkey;
        // deleting...
        list store = llCSV2List(llList2String(llGetPrimitiveParams([PRIM_TEXT]), 0));
        integer i = llListFindList(store, (list)((string)aKey));
        if (q != "delete") jump add;
        store = llDeleteSubList(store, i, i);
        llSetPrimitiveParams([PRIM_TEXT, llList2CSV(store), < 0, 0, 0 > , .0]);
        llSay(0, "The avatar has been removed from the access list.");        
@add;
        if (q != "add") return;
        if (i != -1) return;
        store += aKey;
        llSetPrimitiveParams([PRIM_TEXT, llList2CSV(store), < 0, 0, 0 > , .0]);
        llSay(0, "The avatar has been added to the access list.");
    }
    collision_start(integer num) {
        list store = llCSV2List(llList2String(llGetPrimitiveParams([PRIM_TEXT]), 0));
        --num;
        do {
            key aKey = llDetectedKey(num);
            // if the collider is an avatar on the access list skip
            if (llListFindList(store, (list)((string) aKey)) != -1 || llListFindList(ADMIN, (list)((string) aKey)) != -1) {
                llSetStatus(STATUS_PHANTOM, TRUE);
                jump continue;
            }
            // if the collider is not on the access list.
            llSay(0, "Sorry, you are not allowed into this area.");
            // the vector here, <x, y, z> represents the axes of the object.
            // for example, a vector < 100, 0, 0 > will push the avatar on 
            // the x-axis with a 100m/s impulse.
            llPushObject(aKey, < 1000, 0, 0 > , ZERO_VECTOR, FALSE);
@continue;
        } while (--num > -1);
        llSleep(.2);
        llSetStatus(STATUS_PHANTOM, FALSE);
 
    }
    touch_start(integer num) {
        key aKey = llDetectedKey(0);
        list store = llCSV2List(llList2String(llGetPrimitiveParams([PRIM_TEXT]), 0));
        do {
            if (llListFindList(ADMIN, (list)((string) aKey)) != -1) jump continue;
            if (llListFindList(store, (list)((string) aKey)) == -1) jump continue;
            llDie();
@continue;
            store = llDeleteSubList(store, 0, 0);
        } while (llGetListLength(store));
    }
}