OsMessageAttachments

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
 
(12 intermediate revisions by one user not shown)
Line 2: Line 2:
 
|threat_level=Moderate
 
|threat_level=Moderate
 
|permissions=${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
 
|permissions=${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
|delay=0
+
|delay= (0.1 plus 0.010 per prim)
 
|function_syntax= osMessageAttachments(key avatar, string message, list attachmentPoints, integer options);
 
|function_syntax= osMessageAttachments(key avatar, string message, list attachmentPoints, integer options);
 
|description=
 
|description=
 
Sends a specified message to the specified avatar's attachments on the specified attachment points.
 
Sends a specified message to the specified avatar's attachments on the specified attachment points.
 
calling with [[OSSL Constants/OS_ATTACH_MSG_ALL|OS_ATTACH_MSG_ALL]] as attachpoint sends the message to attachments on every point<br>
 
[[OSSL Constants/OS_ATTACH_MSG_INVERT_POINTS|OS_ATTACH_MSG_INVERT_POINTS]] || 1 || invert how the attachment points list should be treated
 
[[OSSL Constants/OS_ATTACH_MSG_OBJECT_CREATOR|OS_ATTACH_MSG_OBJECT_CREATOR]] || 2 || send only to those have the same CreatorID with host object CreatorID
 
[[OSSL Constants/OS_ATTACH_MSG_SCRIPT_CREATOR|OS_ATTACH_MSG_SCRIPT_CREATOR]] || 4 || send only to those have the same CreatorID with sender script CreatorID
 
  
 
Behaves as [[osMessageObject]], without the sending script needing to know the attachment keys in advance.
 
Behaves as [[osMessageObject]], without the sending script needing to know the attachment keys in advance.
Line 16: Line 11:
 
This is incompatible with the normal use of dataserver event on scripts the receiving prim.
 
This is incompatible with the normal use of dataserver event on scripts the receiving prim.
 
</div>
 
</div>
 +
 +
Options:
 +
* [[OSSL Constants/OS_ATTACH_MSG_INVERT_POINTS|OS_ATTACH_MSG_INVERT_POINTS]] invert how the attachment points list should be treated. Will send to all but the listed ones
 +
* [[OSSL Constants/OS_ATTACH_MSG_OBJECT_CREATOR|OS_ATTACH_MSG_OBJECT_CREATOR]] send only to those attachments that have the same CreatorID as the script host prim
 +
* [[OSSL Constants/OS_ATTACH_MSG_SCRIPT_CREATOR|OS_ATTACH_MSG_SCRIPT_CREATOR]] send only to those attachments  that have the same CreatorID as the script itself.
 +
 +
This options can be combined with binary or &#124;<br>
 +
 +
Calling with [[OSSL Constants/OS_ATTACH_MSG_ALL|OS_ATTACH_MSG_ALL]] in list attachmentPoints will sends the message to attachments on every point. If [[OSSL Constants/OS_ATTACH_MSG_INVERT_POINTS|OS_ATTACH_MSG_INVERT_POINTS]] is also provide, the message is ignored<br>
  
 
|ossl_example=<source lang="lsl">
 
|ossl_example=<source lang="lsl">
Line 99: Line 103:
 
</source>
 
</source>
 
|additional_info=This function was added in 0.7.5-post-fixes
 
|additional_info=This function was added in 0.7.5-post-fixes
See the [[OSSL Constants]] page for information about the pre-defined constants that can be used for the 'options' argument of this function call.
 
 
}}
 
}}

Latest revision as of 19:35, 5 January 2022

osMessageAttachments(key avatar, string message, list attachmentPoints, integer options);
Sends a specified message to the specified avatar's attachments on the specified attachment points.

Behaves as osMessageObject, without the sending script needing to know the attachment keys in advance.

This is incompatible with the normal use of dataserver event on scripts the receiving prim.

Options:

This options can be combined with binary or |

Calling with OS_ATTACH_MSG_ALL in list attachmentPoints will sends the message to attachments on every point. If OS_ATTACH_MSG_INVERT_POINTS is also provide, the message is ignored

Threat Level Moderate
Permissions ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Extra Delay (0.1 plus 0.010 per prim) seconds
Example(s)
string NPCName = "osMessageAttachments";
key npc;
 
default
{
    state_entry()
    {
        llSensor("", NULL_KEY, OS_NPC, 96, TWO_PI);
    }
 
    sensor(integer d)
    {
        integer i;
        for(i=0;i<d;++i)
        {
            if(llDetectedName(i) == NPCName + " NPC")
            {
                osNpcRemove(llDetectedKey(i));
            }
        }
 
        llSensor("", NULL_KEY, OS_NPC, 96, TWO_PI);
    }
 
    no_sensor()
    {
        state ready;
    }
}
 
 
state ready
{
    state_entry()
    {
        npc = osNpcCreate(NPCName, "NPC", llGetPos(), llGetOwner());
    }
 
    touch_start(integer p)
    {
        integer i;
        integer wasNPC = FALSE;
        for(i=0;i<p;++i)
        {
            key detected = llDetectedKey(i);
            if(!wasNPC)
            {
                wasNPC = detected == npc;
            }
            list attachments = osGetNumberOfAttachments(detected, [
                ATTACH_HEAD,
                ATTACH_LHAND,
                ATTACH_RHAND
            ]);
            list attachmentsToMessage = [];
            integer j;
            integer k = llGetListLength(attachments);
            integer l;
            for(j=0;j<k;j+=2){
                l = llList2Integer(attachments, j);
                if(l > 0 && llList2Integer(attachments, j + 1) > 0){
                    attachmentsToMessage += [l];
                }
            }
            osMessageAttachments(detected, "foo", attachmentsToMessage, 0);
            osMessageAttachments(detected, "bar", attachmentsToMessage, OS_ATTACH_MSG_INVERT_POINTS);
            osMessageAttachments(detected, "baz", [OS_ATTACH_MSG_ALL], 0);
            osMessageAttachments(detected, "will never be sent", [OS_ATTACH_MSG_ALL], OS_ATTACH_MSG_INVERT_POINTS);
 
            osMessageAttachments(detected, "heard by both feet", [ATTACH_LFOOT, ATTACH_RFOOT], 0);
            osMessageAttachments(detected, "heard by object creator feet", [ATTACH_LFOOT, ATTACH_RFOOT], OS_ATTACH_MSG_OBJECT_CREATOR);
            osMessageAttachments(detected, "heard by script creator feet", [ATTACH_LFOOT, ATTACH_RFOOT], OS_ATTACH_MSG_SCRIPT_CREATOR);
        }
        if(!wasNPC)
        {
            osNpcTouch(npc, llGetKey(), 0);
        }
    }
}
Notes
This function was added in 0.7.5-post-fixes
Personal tools
General
About This Wiki