Template:Needs Translation/
函数名
|
Function: key llGetInventoryKey( string name )
|
参数:string name–an item in the inventory of the prim this script is in
|
返回值:返回一个键,该键是库存名称的UUID
|
注意事项
|
注意事项
- 如果在prim的库存中没有名字,那么在DEBUG_CHANNEL上就会喊出一个错误。
- 存货项目通常是指向资产的记录,但它们不是实际的资产。
- 多个库存物品可以指向相同的资产并返回相同的键。
- 一些新创建的库存条目得到默认键,直到他们被编辑和保存:
- 新创建的notecard条目目前使用NULL_KEY,直到它们被编辑和保存。
- 在被编辑和保存之前,新创建的脚本条目指向“Hello Avatar”脚本(“d0d40b7c-e32b-3bcb-3346-2be8470093c0”,这不是一个保证的默认值)。
- 大多数其他库存条目在创建时都被赋予了唯一的资产键,但这依赖于客户端的合作,并且不能保证。
- 当一个资产被“编辑”时,一个新的资产键被分配给编辑。用于打开资产进行编辑的库存项将使用新的资产键进行更新。
- 共享原始资产的其他库存项目不会使用新的资产密钥进行更新。
|
示例
|
// Put this script in an empty prim, and drag a full-perm texture into the prim's contents to find out its UUID
default
{
changed(integer change)
{
if (change & CHANGED_INVENTORY) // if there has been a change to the prim's contents ...
{
string name = llGetInventoryName(INVENTORY_TEXTURE, 0);
if (name) // if a texture exists ...
{
key uuid = llGetInventoryKey(name);
if (uuid) // if the uuid is valid ...
llOwnerSay( "The UUID of '" + name + "' is " + (string) uuid);
else // texture was not full-perm
llOwnerSay( "The UUID of '" + name + "' could not be determined");
}
}
}
}
string item = "Default";
default
{
state_entry()
{
llOwnerSay("Touch to get information about \"" + item + "\".");
}
touch_start(integer total_number)
{
integer type = llGetInventoryType(item);
integer index = llListFindList([ INVENTORY_NONE,
INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_LANDMARK, INVENTORY_CLOTHING,
INVENTORY_OBJECT, INVENTORY_NOTECARD, INVENTORY_SCRIPT, INVENTORY_BODYPART,
INVENTORY_ANIMATION, INVENTORY_GESTURE], [type]);
string name = llList2String(["does not exist",
"texture", "sound", "landmark", "clothing",
"object", "notecard", "script", "body part",
"animation", "gesture"], index);
llOwnerSay("Type: " + name);
if(type == INVENTORY_NONE)
return;
integer owner_perms = llGetInventoryPermMask(item, MASK_OWNER);
list perms;
if(owner_perms & PERM_COPY)
perms += "Copy";
if(owner_perms & PERM_MODIFY)
perms += "Modify";
if(owner_perms & PERM_TRANSFER)
perms += "Transfer";
if(owner_perms & PERM_MOVE)
perms += "Move";
llOwnerSay("Perms: " + llList2CSV(perms));
integer temp = PERM_COPY | PERM_MODIFY | PERM_TRANSFER;
if((owner_perms & temp) != temp)
return;
llOwnerSay("Key: " + (string)llGetInventoryKey(item));
}
}
|