LlRequestExperiencePermissions
首页 | 函数 | 事件 | 类型 | 操作符 | 常数 | Flow Control | Script Library | Categorized Library | Tutorials |
函数名 |
---|
Function: llRequestExperiencePermissions( key agent, string name ); |
参数:• key agent – 要向其请求权限的代理的密钥
• string name – 已废弃,不再使用 |
返回值:请求代理同意参与剧本的体验。
这个请求类似于具有以下所有权限的llRequestPermissions: PERMISSION_TAKE_CONTROLS、PERMISSION_TRIGGER_ANIMATION、PERMISSION_ATTACH、PERMISSION_TRACK_CAMERA、PERMISSION_CONTROL_CAMERA和PERMISSION_TELEPORT。然而,与llRequestPermissions不同的是,允许或阻止请求的决定是持久的,并且适用于使用经验网格范围的所有脚本。 经验中的脚本对llRequestExperiencePermissions的后续调用将自动收到相同的响应,而不需要用户交互。 为响应此调用,将生成experience_permissions或experience_permissions_denied。如果代理没有给出响应,请求将在至少5分钟后超时。在此期间,同一脚本可以发出多个请求,但该脚本一次只能对一个代理拥有权限。 “上帝”模式下的代理总是会看到权限对话框,即使之前的经验已经被批准。 如果脚本被重新配置、移动到另一个区域或重新设置,未完成的权限请求将丢失。 要使此函数工作,必须将脚本编译成Experience |
注意事项 |
---|
如果您重新编译一个以前与经验相关联的脚本,但在这样做的客户端缺乏将脚本编译成经验的能力,那么脚本将丢失相关的经验。 |
示例 |
---|
这是一个外壳的HUD分配器。它通过碰撞事件检测AV,然后重新启动一个对象,该对象将请求经验许可并附加到化身上
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); } } } 这个脚本用于被rezzed的对象。它请求体验权限,然后将自己附加到化身上。它必须检查各种失败,如被拒绝的权限和未能附加,并在出现错误时删除自己。 // 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(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(); } } } |
相关函数 |
---|
无 |
相关事件 |
---|
experience_permissions_denied |