The function that we will see is handy when it comes to deliver something to someone through an object (which is an item, a landmark, a notecard, etc.).
Saturday, October 2, 2010
Gurgling Noises And Heartbeat In Stomach
llGiveInventory (): distribute something via objects
The function that we will see is handy when it comes to deliver something to someone through an object (which is an item, a landmark, a notecard, etc.).
For example, many often ask me a script of welcome, to be included in a board, giving the landmark
The function that we will see is handy when it comes to deliver something to someone through an object (which is an item, a landmark, a notecard, etc.).
and notecard with the rules of the sim, presentation etc ... Finally I will have the excuse to fuck off and send them all to read here!
The function is trivial, it is used
llGiveInventory
() and requires two parameters: the
-
key target (ie the object or target of the avatar uuid).
-string
the inventory (ie, the object name to give this inventory of the prim).
A practical example may be this:
default
{
touch_start
(integer TOTAL_NUMBER) {
llGiveInventory
(
llDetectedKey
(0),
llGetInventoryName (INVENTORY_NOTECARD, 0));}
}
We just wrote that to the touch, the script over to those who have clicked on the first ( llDetectedKey (0)), the object type in the inventory of notecards, and to 0 (ie the first item in the inventory). We will see that in fact the number of positions, always starts from 0, not 1. All very simple, simply specify the type of object to be given through the function llGetInventoryName
(). The type of object can be anything:
For a full table, look here:
http://wiki.secondlife.com/wiki/LlGetInventoryName
Now let's do more complex: the script for an object that upon arrival, deliver a landmark and a notecard
, as well as give a nice welcome message. We could try to
two ways: using a sensor-
(whose use is explained in the previous lesson)
-Using a collision (also explained) The best solution is undoubtedly to use the collision, because repeated using a sensor (
llSensorRepeat
()) would only overloading the server, since it is always an active process that scans every few seconds. The collision can be applied in a rather prim invisible, or landing surface of the avatar, and without heavy impact on the performance of the sim. Try this:
default { collision_start (integer num_detected) {
llSay
(0, "Hello" +
llDetectedName (0) + ", welcome to our beautiful land! Here are the landmark and notecard! ");
llGiveInventory (
llDetectedKey
(0),
llGetInventoryName
(INVENTORY_NOTECARD, 0));
llGiveInventory ( llDetectedKey
(0),
llGetInventoryName
(INVENTORY_LANDMARK, 0));}
} very simple: once you hit (or walked), the first will welcome and the two items in the inventory.
If we wanted to give another example, Landmark beyond that, we should add another line and write 1 instead of 0, thus:
llGiveInventory ( llDetectedKey
(0),
llGetInventoryName
(INVENTORY_LANDMARK,
NOTE: The figure shows a landmark and a notecard: both have position 0, because they are the first for any kind of object: if we had a second Landmark, we had a one in position 0 and position 1
not make the mistake of thinking that the Landmark is in position 0 and position 1 Notecard!
only downside
Whenever the avatar touches the prim, always will yet another welcome message, and the two objects. To remedy this small problem, we will use later the
lists.
The concept is very simple: each avatar that has a collision, will be stored in a list, so that a subsequent collision with the object will "remember" him.
But that's another story ..:)
Subscribe to:
Post Comments (Atom)
it was in fact for "pima position", 1 stands for "second place" in the inventory.
0 comments:
Post a Comment