189
dataserver(key requestID, string data) {
vector regionCoords = (vector)data;
llOwnerSay("Landmark is at " + (string)regionCoords );
}
}
TABLE 8.2: INVENTORY INFORMATION FUNCTIONS
FUNCTION BEHAVIOR
integer llGetInventoryNumber(integer type)
Returns an integer that is the number of items of a given
type in the prim's inventory.
string llGetInventoryName(integer type,
integer number)
Returns a string that is the name of the inventory item
number of type. Returns an empty string if nothing is found.
integer llGetInventoryType(string name)
Returns an integer that is the type of the inventory item
name. Using the item's key will not work.
key llGetInventoryCreator(string name)
Returns a key of the creator of the inventory name. Using
the item's key will not work.
key llGetInventoryKey(string name)
Returns a key that is the UUID of the inventory name. If
you do not have full permissions on the inventory object,
this returns NULL_KEY.
key llRequestInventoryData(string name)
Returns to the dataserver query a key that is a unique
identifier. A dataserver() event will be triggered when
the data is ready. Currently valid only for landmarks.
Containers are objects that hold on to things until they are needed in the environment or in interactions
with residents. Containers that give out landmarks and notecards are prime examples of interaction tools
you will find necessary every day in Second Life. When you've given away singleton objects a couple of
times, you will realize how convenient it is to give a long list of items at one time.
PLEASE TAKE A NOTE(CARD)
Listing 8.2 shows a simple notecard giver. At SYW HQ, it is embodied in a fountain that offers each sensed
avatar a notecard containing a horoscope. The core is a simple one-liner that offers each detected avatar
the first (i.e., zeroth) notecard item found in inventory:
llGiveInventory(llDetectedKey(i), llGetInventoryName(INVENTORY_NOTECARD, 0));
Listing 8.2: Notecard Giver
integer MEMORY_LENGTH = 25;
list gAvatars;
add_avatar(string name) {
gAvatars += name;
if (llGetListLength(gAvatars) > MEMORY_LENGTH) {
gAvatars = llDeleteSubList(gAvatars,0,0);
}
}