LlRequestExperiencePermissions

De DigiWiki.

(Différences entre les versions)
Djphil (discuter | contributions)
(Page créée avec « This is a shell for a HUD Dispenser. It detects an AV by the collision event, then rezzes an object that will request experience permissions and attach to the avatar <lsl> de… »)

Version actuelle en date du 20 mai 2015 à 12:00

This is a shell for a HUD Dispenser. It detects an AV by the collision event, then rezzes an object that will request experience permissions and attach to the avatar

default
{
    state_entry()
    {
        llVolumeDetect(TRUE);
    }
 
    collision_start(integer NumberOfCollisions)
    {
        integer i = 0;
        for(; i < NumberOfCollisions; i++)
        {
            integer channel = llRound(llFrand(-1000));
            key give_to = llDetectedKey(i);
            llSay(0, "Rezzing HUD for " + (string)give_to + " using channel " + (string)channel);
            llRezObject(llGetInventoryName(INVENTORY_OBJECT, 0), llGetPos(), ZERO_VECTOR, ZERO_ROTATION, channel);
            llRegionSay(channel, "ATTACH|" + (string)give_to);
        }
    }
}

This script is for the object that is rezzed. It requests experience permissions and then attaches itself to the avatar. It must check for various failures such as denied permissions and failure to attach, and deletes itself when there is an error.

// Example script for LSL Experience Tools attachment
// This script runs on an object that is rezzed in-world which gets
// an Experience permissions and then attaches to an AV.
 
integer listener;
integer msg_channel;
 
integer log_spam_channel = 0;       // Change this or remove llSay() commands
 
default
{
    on_rez(integer start_parameter)
    {   // Start listening for a message from rezzer
        msg_channel = start_parameter;
        llSay(log_spam_channel, "Test HUD has been rezzed");
        listener = llListen(start_parameter, "", NULL_KEY, "");
    }
 
    listen(integer channel, string name, key id, string text)
    {   // Listen for the message from the rezzer with the target agent key
        if (channel == msg_channel)
        {   // Ask for the experience permission
            list msg = llParseString2List(text, ["|"], []);
            llSay(log_spam_channel, "Trying experience permissions request to " + llList2String(msg, 1));
            llRequestExperiencePermissions((key)llList2String(msg, 1), "");
            llListenRemove(listener);
            llSetTimerEvent(60.0);
        }
    }
 
    experience_permissions(key target_id)
    {   // Permissions granted, so attach to the AV
        llSay(log_spam_channel, "Trying llAttachToAvatarTemp()");
        llAttachToAvatarTemp">llAttachToAvatarTemp(ATTACH_HUD_CENTER_1);
        llSay(log_spam_channel, "After llAttachToAvatarTemp() with llGetAttached() returning " + (string)llGetAttached());
        llSetTimerEvent(0.0);
        if (llGetAttached() == 0)
        {   // Attaching failed
            llDie();
        }
    }
 
    experience_permissions_denied( key agent_id, integer reason )
    {   // Permissions denied, so go away
        llSay(log_spam_channel, "Denied experience permissions for " + (string)agent_id + " due to reason #" + (string) reason);
        llDie();
    }
 
    attach( key id )
    {   // Attached or detached from the avatar
        if (id)
        {
            llSetTimerEvent(0.0);
            llSay(log_spam_channel, "Now attached with a key " + (string)id + " and llGetAttached() returning " + (string)llGetAttached());
            // From this point, the object can start doing whatever it needs to do.
            state running;
        }
        else
        {
            llSay(log_spam_channel, "No longer attached");
            llDie();
        }
    }
 
    timer()
    {   // Use a timer to catch no permissions response
        llSay(log_spam_channel, "Permissions timer expired");
        llDie();
    }
}
 
// This state starts when permissions are granted and the object is properly attached
state running
{
    state_entry()
    {
        llSay(log_spam_channel, "off and running!");
    }
 
    attach(key id)
    {
        if (id == NULL_KEY)
        {   // if the object ever un-attaches, make sure it deletes itself
            llSay(log_spam_channel, "No longer attached");
            llDie();
        }
    }
}
Outils personnels
  • Cette page a été consultée 1 084 fois.
donate
Google Ads