Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

message after "stand up"

Mops McLaglen
Registered User
Join date: 10 Jan 2007
Posts: 4
04-29-2007 05:45
Hi all,

please note that my scripting skills are very basic, so I appologize in advance if my question is dumb.

I would like an object that includes a sit pose to give a message after the avatar stands up. Preferably with a short time delay.

I am not sure what event I should use to detect that the avatar stands up.
Seems to be an changed event. But an avatar sitting on an object is too... so, how to differ?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
04-29-2007 06:30
From: Mops McLaglen
Hi all,

please note that my scripting skills are very basic, so I appologize in advance if my question is dumb.

I would like an object that includes a sit pose to give a message after the avatar stands up. Preferably with a short time delay.

I am not sure what event I should use to detect that the avatar stands up.
Seems to be an changed event. But an avatar sitting on an object is too... so, how to differ?


The difference is the result of the llAvatarOnSitTarget call. If tehre is an avatar it returns their key, other wise it returns NULL_KEY.
Mops McLaglen
Registered User
Join date: 10 Jan 2007
Posts: 4
04-29-2007 07:23
Hi Newgate,

Thx for your reply, that was really helpfull!

But I have another question...

That's the script I use:

CODE

default {
state_entry() {
llSitTarget ( <1.70468, -0.00165, -0.61064>, <1.00000, -0.00000, 0.00000, 0.00000>);
}

changed(integer change) {
if (change & CHANGED_LINK) {
if (llAvatarOnSitTarget() == NULL_KEY) {
llSleep(3.0);
llSay(0, "bla bla bla");

}
}
}
}


To make it work I had to insert the excact SitTarget parameters.
Is there a way, not to put in the numbers but to have a kind of variable that gets the numbers from elsewhere?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
04-30-2007 06:39
From: Mops McLaglen
Hi Newgate,

Thx for your reply, that was really helpfull!

But I have another question...

That's the script I use:

CODE

default {
state_entry() {
llSitTarget ( <1.70468, -0.00165, -0.61064>, <1.00000, -0.00000, 0.00000, 0.00000>);
}

changed(integer change) {
if (change & CHANGED_LINK) {
if (llAvatarOnSitTarget() == NULL_KEY) {
llSleep(3.0);
llSay(0, "bla bla bla");

}
}
}
}


To make it work I had to insert the excact SitTarget parameters.
Is there a way, not to put in the numbers but to have a kind of variable that gets the numbers from elsewhere?



yes several.
You can make it such that the sit target is read from the description field of the object, from a notecard or any other means you may wish to devise!
Mops McLaglen
Registered User
Join date: 10 Jan 2007
Posts: 4
05-02-2007 04:47
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.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-02-2007 05:40
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>
CODE


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.

CODE

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.
Mops McLaglen
Registered User
Join date: 10 Jan 2007
Posts: 4
05-02-2007 06:09
Great!

That should be enough to work with.

Thank you!