object_transport.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2014 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueGet(string k, string data) {
    if(llStringLength(data) == 0) return "";
    if(llStringLength(k) == 0) return "";
    list a = llParseStringKeepNulls(data, ["&", "="], []);
    integer i = llListFindList(llList2ListStrided(a, 0, -1, 2), [ k ]);
    if(i != -1) return llList2String(a, 2*i+1);
    return "";
}
 
vector destination = ZERO_VECTOR;
 
default {
    listen(integer channel, string name, key id, string message) {
        destination = (vector)wasKeyValueGet("position", message);
        state teleport;
    }
    on_rez(integer num) {
        if(num == 0) return;
        llListen(num, "", "", "");
    }
}
 
state teleport {
    state_entry() {
        llSetClickAction(CLICK_ACTION_SIT);
        llSitTarget(<0,0,1>, ZERO_ROTATION);
    }
    changed(integer change) {
        if(change & CHANGED_LINK) {
            key avatar = llAvatarOnSitTarget();
            if(avatar) {
                llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_TEMP_ON_REZ, FALSE]);
                llSetRegionPos(destination);
                state arrive;
            }
        }
    }
}
 
state arrive {
    state_entry() {
        llSetTimerEvent(1);
    }
    timer() {
        key avatar = llAvatarOnSitTarget();
        if(avatar) {
            llUnSit(avatar);
        }
        llDie();
    }
}