From: Mops McLaglen
Do you mind to tell me a bit more about how to do this?
I am more than willing to learn more about scripting. But I never had any experience with scripting before.
I find it quite difficult to get the information I need. Most of the time I search the forums, pick a line here and a line there, and then try to put it together to get a working script.
So any hint would be great.
The 'simple' version is to use the objects description field.
However this suffers from a limitation in that changing it does not trigger a changed event and so you end up having to either reset the script each time you change it or just continually reread it.
The code below will read both the sit target and rotation values from the description field stored as sit target ! rotation i.e. <1.70468, -0.00165, -0.61064> ! <1.00000, -0.00000, 0.00000, 0.00000>
UpdateSitTarget()
{
string desc = string llGetObjectDesc();
list data = llParseString2List(desc, ["!"],[""]);
vector v = (vector)llList2String(data,0);
rotation r = (rotation)llList2String(data,1);
llSitTarget ( v, r);
}
default
{
state_entry()
{
UpdateSitTarget();
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() == NULL_KEY)
{
llSleep(3.0);
llSay(0, "bla bla bla");
// reread the sit target to account for updates.
// This is only needed if you plan to change it often
UpdateSitTarget();
}
}
}
}
You can also use a notecard name to store the data. The advantage is that renaming the noetcard will trigger a changed event.
The following function will read the one and only notecard in the object's inventory and use its name to obtain the data.
UpdateSitTarget()
{
string desc = string llGetInventoryName(INVENTORY_NOTECARD, 0);
list data = llParseString2List(desc, ["!"],[""]);
vector v = (vector)llList2String(data,0);
rotation r = (rotation)llList2String(data,1);
llSitTarget ( v, r);
}
default
{
state_entry()
{
UpdateSitTarget();
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() == NULL_KEY)
{
llSleep(3.0);
llSay(0, "bla bla bla");
}
}
else if(change & CHANGED_INVENTORY)UpdateSitTarget();
}
}
To use a notecard is a bit, ok quite a lot, more complex. And also way over the top for what you are trying to do. However if you want an example try this
thread for details.