Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Animating Other Avatars

Cyrus Odets
Registered User
Join date: 5 Oct 2005
Posts: 51
10-31-2005 07:59
Greets,

I've been scripting for a couple weeks now and am sorta slowly working through examples and common tasks people do...in order to 'learn by doing'.

My last little project was to create an object that holds several animations, and then to be able to type in a command to cause friend's avatars nearby to be able to perform those animations.

For example...I might have the following animations loaded into my object which I then 'attach': dance1, jumpUpandDown, stompfeet, bow

So, if I was surrounded by 4 friends....I could cause my device to have one friend perform dance1, another friend perform jumpUpandDown, another do stompfeet, and another bow.

I guess the idea here is to be 'remote controlling' my friend's avatars.

So far I was able to get a simple version of this script to work (Yay for me! :) ). I've been using it to test animating my own avatar, running animations on another avatar, running animations on multiple other avatars while running a separate animation on myself, running several different animations on several different avatars while running a yet different animation on myself, etc. etc.

However, now I'm sorta going back through and finding better ways to do things.

My question is this:

What is the best way to animate another person's avatar with an animation in the object you are wearing....and to do so with multiple avatars...so...for example...you might use a command-line interface to type something like this:

/90 "Bob Odets" dance1 <--- Cause Bob Odets to begin to animate the dance1 animation that I have in my object.

So far, in my script in its 'primitive' form I've been using a sensor to detect avatars in my immediate area, then using llDetectedName to retrieve their names and compare those names to my friends...to make sure that I don't attempt to animate anyone who wasn't intended, then use llDetectedKey to retrieve the avatars key and feed that to llRequestPermissions to get permissions to animate that avatar.

So, right now, my script can't animate others based on a command-line specification...only those that are within the sensor distance and those that I hard-code in the script.

I'm wondering if there is a better, or more efficient way to do this?

The hard part for me was figuring out how to get the target avatars key in order to request their permissions....and then on top of that...figuring out how to tell Second Life exactly WHICH avatar was my target.

So any advice, pointers, or help in those areas would be greatly appreciated. Thanks!
Cyrus Odets
Registered User
Join date: 5 Oct 2005
Posts: 51
11-01-2005 10:18
Hmmm...maybe my initial post was too darned long and not to the point enough.

I'll try rephrasing here and simplifying.

If you have an object in YOUR inventory with animations inside, and you wish that object in your inventory to request permissions from one or more nearby avatars, and then should they accept, they begin performing the animations within that object...

How do you get the 'other' avatar's ID (Key) so that you can request permissions and begin the animation?

Would you somehow have each avatar wearing some unique object that somehow sends that avatar ID back to your object?

Would you use a sensor to detect the avatars in the immediate area and then use llDetectedKey?

Something similar?

Thanks!
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
11-01-2005 10:55
From: Cyrus Odets
Hmmm...maybe my initial post was too darned long and not to the point enough.

I'll try rephrasing here and simplifying.

If you have an object in YOUR inventory with animations inside, and you wish that object in your inventory to request permissions from one or more nearby avatars, and then should they accept, they begin performing the animations within that object...

How do you get the 'other' avatar's ID (Key) so that you can request permissions and begin the animation?

Would you somehow have each avatar wearing some unique object that somehow sends that avatar ID back to your object?

Would you use a sensor to detect the avatars in the immediate area and then use llDetectedKey?

Something similar?

Thanks!


In order to get another agent's key, you either:

a) Need to have their key hard coded in your script

b) Detect their key using an event that can pass it, such as Touch, Collision, or Sensor.

Hope this helps! :)

To answer your specific questions.......

Would you somehow have each avatar wearing some unique object that somehow sends that avatar ID back to your object? You could, sure

Would you use a sensor to detect the avatars in the immediate area and then use llDetectedKey? You could do this, too

Or, you could even create a large phantom/invisible Bubble around yourself, and do a collision detect :D

I'm no power-scripter - I'm sure others may have some additional ideas :)
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
Cyrus Odets
Registered User
Join date: 5 Oct 2005
Posts: 51
11-01-2005 11:34
Yup...thats actually helping alot so far. I'm just having a hard time understanding the best ways to pass all these keys around and obtain the right keys for the right things.

Let me be more specific on an example.

Lets say that I want my script to be able to use a command to get permissions like this:

/58 animate John Odets

If I understand correctly, in order to animate John...I need his Avatar ID...is there an elegant way to do this so that it would work with the above command line thingie?

Forgive me if I'm really vague....as most new scripters (i'd imagine) I'm just trying to wrap my mind around this whole "How do I get that avatars key" stuff.

Thanks again :)
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
11-01-2005 11:46
From: Cyrus Odets
Yup...thats actually helping alot so far. I'm just having a hard time understanding the best ways to pass all these keys around and obtain the right keys for the right things.

Let me be more specific on an example.

Lets say that I want my script to be able to use a command to get permissions like this:

/58 animate John Odets

If I understand correctly, in order to animate John...I need his Avatar ID...is there an elegant way to do this so that it would work with the above command line thingie?

Forgive me if I'm really vague....as most new scripters (i'd imagine) I'm just trying to wrap my mind around this whole "How do I get that avatars key" stuff.

Thanks again :)



Hrm... since you listed having John wear some sort of attachement - why not have all the work done there? Have John's attachment itself do a listen for your command, then request perms & call the animation itself.

Since John is wearing the attachment, you could easily do an llGetOwnerKey & llGetOwner, since seeing as how he's wearing the attachment, he must be the owner.
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-01-2005 13:36
From: Cyrus Odets
How do you get the 'other' avatar's ID (Key) so that you can request permissions and begin the animation?


At some point in time you have to have the avatar interact with the object. In general, you probably don't want to be asking permission to animate someone on the other side of the sim... or the grid... so what's wrong with using llSensor?

If you want this to be some kind of remote controller, how about this?

CODE

touch(integer num)
{
list info = [ llDetectedName(0), llDetectedKey(0) ];
if(llListFindList(log, info) == -1)
log = log + info;
}

listen(integer chan, string name, key id, string message)
{
list l = llParseString2List(message, [" "], []);
if(llList2String(0) == "animate")
{
string name = llToLower(llList2String(l, 1));
integer len = llStringLength(name);
integer i;
integer n = llGetListLength(log);
for(i = 0; i < n; i+=2)
if(llToLower(llGetSubString(llList2String(log, i), len)) == name)
{
animate_key(llList2String(log, i+1));
return;
}
}
}
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
11-01-2005 19:05
Cyrus, my Dancy Jockey Cube forces ppl dances which I choose. It is why this is called Jockey. ;)
Ok, you need ppl's key and their accepting the permission. It is the best way that you tell ppl to touch the object included the script and accept it. Even though you got their key secretly, they would doubt what happend when the animation request dialog box popped up.

Argent, if we were forced to animate when someone just got our key, it would be frightful. :D
_____________________
:) Seagel Neville :)
Cyrus Odets
Registered User
Join date: 5 Oct 2005
Posts: 51
11-02-2005 08:10
From: someone

Cyrus, my Dancy Jockey Cube forces ppl dances which I choose. It is why this is called Jockey.
Ok, you need ppl's key and their accepting the permission. It is the best way that you tell ppl to touch the object included the script and accept it. Even though you got their key secretly, they would doubt what happend when the animation request dialog box popped up.


Yup...thats pretty much exactly the type of thing I'm doing...and after getting some help, and reading some advice....you're advice is exactly what I'm going with. I tried out some different methods and the 'touch' method seems to fit my purposes AND be the most efficient without a bunch of 'stuff' out there testing for things and what not. Anyone who wants to be 'remote controlled' touches the sphere so that the sphere can get their permissions. After some testing and goofing with it last night, this worked really well :)

Mostly, this whole thing is just a 'project' for me to be able to cover a bunch of 'aspects' of scripting and expose myself to it....and learn. Sorta of like a self-induced homework assignment from my school days...hehe. Its the way I learn best.

Thanks!
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-02-2005 08:38
From: Seagel Neville

Argent, if we were forced to animate when someone just got our key, it would be frightful. :D
I'm not talking about being forced to animate, I'm just talking about having a dialog box pop up when you're not expecting it. That's intrusive enough.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
11-02-2005 11:21
From: Argent Stonecutter
I'm not talking about being forced to animate, I'm just talking about having a dialog box pop up when you're not expecting it. That's intrusive enough.
Oops. Sorry for that. :o
_____________________
:) Seagel Neville :)