Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Trouble with a chat controlled poseball.

Atom Burma
Registered User
Join date: 30 May 2006
Posts: 685
11-25-2008 04:45
This script was compiled from existing scripts I either had, or sections through these forums. And something is off in it. It will work upon touch, but when people sit on it, I thought the default_anim should start. But it doesn't. It will listen on channel 777 after it gets permissions, which I also think is off, because it does not automatically ask when the person sits. You have to click the pose ball first, which is a bit impractical.

this is the script here...

(code)
list ANIMS = [];
list ANIMS2 = [];
key chave;

integer i;


default

{
state_entry() {
llSitTarget(<-0.15,0,-0.38>, ZERO_ROTATION);
llListen(777, "", NULL_KEY, "";);

if (llGetInventoryNumber(INVENTORY_ANIMATION) <= 12)
{
for (i = 0; i < llGetInventoryNumber(INVENTORY_ANIMATION); i++)
ANIMS += [llGetInventoryName(INVENTORY_ANIMATION, i)];
}
else
{
for (i = 0; i < 11; i++)
ANIMS += [llGetInventoryName(INVENTORY_ANIMATION, i)];
for (i = 11; i < llGetInventoryNumber(INVENTORY_ANIMATION); i++)
ANIMS2 += [llGetInventoryName(INVENTORY_ANIMATION, i)];
ANIMS += "more...";
ANIMS2 += "...back";
}
}

touch_start(integer total_number)
{
chave = llDetectedKey(0);
if ((chave == llGetPermissionsKey())

&& (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
llDialog(chave, "Select the animation you want to play: ", ANIMS, 777);
else
llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
}

run_time_permissions(integer perm)
{
if ((chave == llGetPermissionsKey()) && (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
llDialog(chave, "Select the animation you want to play: ", ANIMS, 777);
}


listen(integer channel, string name, key id, string message)
{
if (channel == 777)
{
if (message == "more...";)
llDialog(chave, "Select the animation you want to play: ", ANIMS2, 777);
else if (message == "...back";)
llDialog(chave, "Select the animation you want to play: ", ANIMS, 777);
else
{
list anims = llGetAnimationList(llGetPermissionsKey()); // get list of animations
integer len = llGetListLength(anims);
for (i = 0; i < len; ++i)
{
llStopAnimation(llList2Key(anims, i));
llSleep(0.2);
}
llStartAnimation("default_anim";);
llStartAnimation(message);
}
}
}

}
(end code)

So I wanted it just to skip the entire dialogue and really just be remotely controlled by chat calls. Just have the default_anim be triggered automatically. And I know the script is a little backward. But I am not sure what the solution is. Any advice would be great, thanks.
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
11-25-2008 05:11
You need to add an event to detect an avatar sitting down. Specifically, use the "changed" event, and you're looking for a CHANGED_LINK happening. If that's the case, then you can find out who the avatar sitting is by using llAvatarOnSitTarget() (it will be NULL_KEY if nobody is sitting).

There's a good example snippet on the LSL wiki:

http://www.lslwiki.net/lslwiki/wakka.php?wakka=changed