Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sit Target that pushes avatar off upon standing up?

Chosen Few
Alpha Channel Slave
Join date: 16 Jan 2004
Posts: 7,496
02-17-2005 14:41
Okay, time for me to acknowledge my limitations. I'm good at modeling, good at texturing, lousy at scripting. I need a little help if someone would be so kind.

What I'm trying to do is make a chair that will cause the avatar to land in front of it instead of on top of it when standing back up. With normal sit targets, the av ends up standing exactly where it sat. I assume the way to do this is to have the object push the avatar forward a little ways when the Stand Up botton is pressed.

I tried the following script, but it didn't work:
CODE

default
{
state_entry()
{
llSitTarget(<-0.18, 0.0, .9>, <0.0, 0.0, 0.0, 1.0>);
}
changed(integer change)
{
if(CHANGED_LINK)
{
key avatar_key = llAvatarOnSitTarget();
if(llAvatarOnSitTarget()==NULL_KEY)
{
llPushObject(avatar_key,<750,0,0>,<0,1,1>,1);
avatar_key="";
}
else
{
avatar_key = llAvatarOnSitTarget();
}
}

}
}

The pushobject seems to have no effect here. The chair behaves exactly the same as a regular sit target.

If someone could correct this and post it here, I'd be most grateful. Thanks in advance. :)
_____________________
.

Land now available for rent in Indigo. Low rates. Quiet, low-lag mainland sim with good neighbors. IM me in-world if you're interested.
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
02-17-2005 15:00
Try adding this:

CODE
key agent = "";
default
{
state_entry()
{
llSitTarget(<-0.18, 0.0, .9>, <0.0, 0.0, 0.0, 1.0>);
}
changed(integer change)
{
if(CHANGED_LINK)
{
if(llAvatarOnSitTarget()==NULL_KEY)
{
llPushObject(agent,<750,0,0>,<0,1,1>,1);
agent = "";
}
else
{
agent = llAvatarOnSitTarget();
}
}

}
}


Your problem is a simple one - you're using a local variable. So, when your function ends, avatar_key goes bye-bye. Storing a global variable will solve this problem. ;)
_____________________
---
Chosen Few
Alpha Channel Slave
Join date: 16 Jan 2004
Posts: 7,496
02-17-2005 16:40
That did the trick. Thanks so much, Jeff.

EDIT: One more question. How can I get it to push on the local X axis instead of a global axis?
_____________________
.

Land now available for rent in Indigo. Low rates. Quiet, low-lag mainland sim with good neighbors. IM me in-world if you're interested.
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
02-17-2005 17:18
From: Chosen Few
One more question. How can I get it to push on the local X axis instead of a global axis?


CODE
rotation rot = llGetRot();
rot.s *= -1;
llPushObject(agent,<750,0,0> / rot,<0,1,1> / rot,1);
_____________________
---