key llRequestInventoryData(string name)
Requests data from
object inventory item name. When data is available, the
dataserver event will be raised with the
key returned from this function in the requested
parameter.
The only request currently implemented is to request data from
landmarks, where the data returned is in the form
"<float, float, float>" which can be directly
cast to a
vector. This
position is in
region local coordinates (that means it's the distance from the region corner) so to convert it into a
global position, just add the result of
llGetRegionCorner.
Note: This function
delays the
script for 1 second.
For a another example using this function see:
llMapDestination
Example:
// llRequestInventoryData Example
// This script gets the distance from the object
// this script is in to the landmark defined by LANDMARK_NAME.
// This landmark must be in the same object as the script.
// Written by Christopher Omega
// Name of landmark.
string LANDMARK_NAME = "**landmark name here**";
// Stores the request identifyer (return value of llRequestInventoryData)
// this value is equal to the first parameter of the dataserver event
// when the dataserver event is returning the data requested.
key inventoryRequestID = NULL_KEY;
default {
state_entry() {
inventoryRequestID = llRequestInventoryData(LANDMARK_NAME);
}
dataserver(key requestID, string data) {
// If dataserver event is the responce to the request
// whose key is stored in the variable inventoryRequestID:
if (requestID == inventoryRequestID) {
// This prevents any dataserver "hiccups":
inventoryRequestID = NULL_KEY;
// When passing landmark names to llRequestInventoryData,
// the resulting dataserver event's string parameter contains the
// location of the landmark in coordinates relative to the region the script
// is currently in. (see wiki page on RegionCoordinates)
vector regionCoords = (vector) data;
vector myPosition = llGetPos();
// Get the distance from my position to the landmark's position.
float distance = llVecDist(myPosition, regionCoords);
llSay(0, LANDMARK_NAME + " is " + (string) distance + " meters away from me.");
}
}
}
This article wasn't helpful for you? Maybe the
related article at the LSL Portal is able to bring enlightenment.
Functions |
Inventory |
Dataserver