Difference between revisions of "LlRequestInventoryData"
Line 72: | Line 72: | ||
state_entry() | state_entry() | ||
{ | { | ||
//complain if there are no | //complain if there are no landmarks | ||
if (llGetInventoryNumber(INVENTORY_LANDMARK) == 0) | if (llGetInventoryNumber(INVENTORY_LANDMARK) == 0) | ||
{ | { |
Revision as of 23:46, 29 February 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: key llRequestInventoryData( string name );156 | Function ID |
1.0 | Forced Delay |
10.0 | Energy |
Requests data from objects inventory object. When data is available the dataserver event will be raised.
Returns a key that is used to identify the dataserver event when it is raised.
• string | name | – | an item in the inventory of the prim this script is in |
name Type | dataserver | Description | ||||
---|---|---|---|---|---|---|
Landmark | (vector) | The vector data received by dataserver is a global position as an offset from the current region's origin (<0,0,0>). To obtain the absolute global position of a landmark, add llGetRegionCorner() to the vector. |
Caveats
- This function causes the script to sleep for 1.0 seconds.
- If name is missing from the prim's inventory then an error is shouted on DEBUG_CHANNEL.
Examples
<lsl>//-- Open map for owner to 1st landmark in object inventory on touch //-- *MUST* be in an attached object (llMapDestination Requirement for non-touch use) key vgKeyOwner;
default {
touch_start( integer vIntNull ) { if (llDetectedKey( 0 ) == vgKeyOwner) { integer vIntLMcount = llGetInventoryNumber( INVENTORY_LANDMARK ); //-- make sure we have a landmark in invetory if (vIntLMcount) { llRequestInventoryData( llGetInventoryName( INVENTORY_LANDMARK, 0 ) ); } } }
dataserver( key vKeyNull, string vStrData ) { //-- because we don't know who touched us in this event, this //-- only works for the owner when called from the dataserver llMapDestination( llGetRegionName(), (vector)vStrData, ZERO_VECTOR ); }
on_rez( integer vIntNull ) { vgKeyOwner = llGetOwner(); }
}</lsl> <lsl>//An easily-configurable teleporter that sets its destination by getting it from a landmark in the prim's inventory //Note: this teleporter is subject to the 300m distance limit for llSitTarget //by Ilse Mannonen
//on state entry, request inventory data and set text for first landmark found in inventory.
//If none, complain
//on getting data, set sit target //on change in inventory, reset script //on sit, TP the person and unsit
//Thanks to Pol Tabla, who wrote the simple sit-teleport script I have adapted here
key requestid; vector dest; vector offset;
default {
state_entry() { //complain if there are no landmarks if (llGetInventoryNumber(INVENTORY_LANDMARK) == 0) { llSay(0, "There are no landmarks in me. You need to put a landmark in me for me to work."); } else { //set floating text according to the LM name llSetText("Teleport to " + llGetInventoryName(INVENTORY_LANDMARK, 0), <1,1,1>, 1); //request the LM data requestid = llRequestInventoryData(llGetInventoryName(INVENTORY_LANDMARK, 0)); } } dataserver(key id, string data) { if (id == requestid) { //data will be in vector format dest = (vector)data; offset = (dest - llGetPos()) * (ZERO_ROTATION / llGetRot()); llSitTarget(offset, llEuler2Rot(<0,-90,0> * DEG_TO_RAD)); } } changed(integer change) { if (change & CHANGED_INVENTORY) { //reset on inventory change, so people don't have to manually reset when they add a new LM llResetScript(); } //when doing "ifs" on bitwise things, it's best to do them separate instead of useing else..if, in case you hit the one in a billion chance when the inventory and link changes are reported in the same event. if (change & CHANGED_LINK) { // and it was a link change llSleep(0.5); // llUnSit works better with this delay if (llAvatarOnSitTarget() != NULL_KEY) { // somebody is sitting on me llUnSit(llAvatarOnSitTarget()); // unsit him } } } on_rez(integer param) { llResetScript(); }}</lsl>
See Also
Functions
• | llMapDestination |