LlGenerateKey

来自人工智能助力教育知识百科
跳转至: 导航搜索

Template:Needs Translation/

函数名
Function: key llGenerateKey( );
参数:无
返回值:返回生成的密钥
注意事项
特定 uuid 版本是一个实现细节,该细节在过去已经更改,将来可能再次更改。

不要依赖于返回到版本5的 uuid。 由于所生成的 uuid 是版本控制的,所以它不应该返回空键值。

示例
default
{
    touch_start(integer num_detected)
    {
        // avatar touching
        key avatarKey = llDetectedKey(0);
        string avatarName = llKey2Name(avatarKey);
 
        // key of the owner
        key owner = llGetOwner();
 
        // generated random key
        key random = llGenerateKey();
 
        // number of objects inside the same prim
        integer numberOfObjects = llGetInventoryNumber(INVENTORY_OBJECT);
 
        if (numberOfObjects)
        {
            // name of first object sorted by name inside the prim's inventory
            string itemName = llGetInventoryName(INVENTORY_OBJECT, 0);
 
            llGiveInventory(avatarKey, itemName);
            llInstantMessage(avatarKey, "Your transaction key is '" + (string)random + "'.");
 
            llInstantMessage(owner, "Transaction record:\n"
                + "receiver: " + avatarName + " (" + (string)avatarKey + ")\n"
                + "item: " + itemName + "\n"
                + "transaction key: " + (string)random);
        }
        else
        {
            // PUBLIC_CHANNEL has the integer value 0
            llSay(PUBLIC_CHANNEL, "No items to give away, sorry!");
        }
    }
}
相关函数
相关事件