Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Object that animates another AV

Storma Amarula
Registered User
Join date: 8 Mar 2005
Posts: 87
04-06-2005 13:39
Hi,

Can anyone guide me to a script snippet that allows me to attach an object to myself and type a "/kiss (AVNAME)" command that would animate another AV. Is it it possible to have multiple commands such as "/kiss (AVNAME)", "/hug (AVNAME)"...etc?

Thank-you
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-06-2005 13:52
I believe this is how to do it... note this uses /1 kiss Avatar Name

CODE
string animation = "stand"; // Animation name here!
g_listener = FALSE; // Listen handler
default
{
state_entry()
{
llListenRemove(g_listener); // For the heck of it
g_listener = llListen(1,"",llGetOwner(),"");
}
on_rez(integer total_number)
{
llListenRemove(g_listener); // For the heck of it
g_listener = llListen(1,"",llGetOwner(),"");
}
listen(integer chan, string str, key id, string msg)
{
if(llToLower(msg) == "kiss")
llSensor(llDeleteSubString(msg,0,4),"",AGENT,20,TWO_PI);
}
sensor(integer total_number)
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
llRequestPermissions(llDetectedKey(0),PERMISSION_TRIGGER_ANIMATION);
}
run_timer_permissions(integer perm)
{
// Uncomment if this is a looping animation
// llSetTimerEvent(5.0);
if(perm)
llStartAnimation(animation);
}
timer()
{
llStopAnimation(animation);
llStopAnimation(animation);
}
}
_____________________
---
Storma Amarula
Registered User
Join date: 8 Mar 2005
Posts: 87
04-06-2005 14:22
Thanks so much for the quick reply! I did have a problem compiling it however...

This line:

g_listener = FALSE; // Listen handler

seems to be generating errors :(
Storma Amarula
Registered User
Join date: 8 Mar 2005
Posts: 87
04-06-2005 14:33
Ok I solved the little issues. I place an animation in the object, rename the string and attach the object to myself. I type /kiss (AVNAME) and it doesn't do anything :P

Any thoughts?


CODE

string animation = "hand_chest"; // Animation name here!
integer g_listener = FALSE; // Listen handler

default
{

state_entry()
{
llListenRemove(g_listener); // For the heck of it
g_listener = llListen(1,"",llGetOwner(),"");
}
on_rez(integer total_number)
{
llListenRemove(g_listener); // For the heck of it
g_listener = llListen(1,"",llGetOwner(),"");
}
listen(integer chan, string str, key id, string msg)
{
if(llToLower(msg) == "kiss")
llSensor(llDeleteSubString(msg,0,4),"",AGENT,20,TWO_PI);
}
sensor(integer total_number)
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
llRequestPermissions(llDetectedKey(0),PERMISSION_TRIGGER_ANIMATION);
}
run_time_permissions(integer perm)
{
// Uncomment if this is a looping animation
// llSetTimerEvent(5.0);
if(perm)
llStartAnimation(animation);
}
timer()
{
llStopAnimation(animation);
llStopAnimation(animation);
}
}
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
04-06-2005 16:02
Time to fix this.

First, a script can only hold the permissions on one av at a time. So to get this to work you would need two scripts (one a slave script).
Second, the listen is borked :P
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Storma Amarula
Registered User
Join date: 8 Mar 2005
Posts: 87
04-06-2005 17:19
Ohh, please tell me how to do this :)
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-06-2005 21:56
What do you want for a quick, untested hack? :D

1) integer g_listener, yes.
2) Fixed the listener to llSubStringIndex, as it should have been.
3) One permission per script? No kidding. Easy to solve.
4) Fixed listener from "str" to "name." Too many link messages. :rolleyes:


CODE
string animation = "stand"; // Animation name here!
integer g_listener = FALSE; // Listen handler
default
{
state_entry()
{
llListenRemove(g_listener); // For the heck of it
g_listener = llListen(1,"",llGetOwner(),"");
}
on_rez(integer total_number)
{
llListenRemove(g_listener); // For the heck of it
g_listener = llListen(1,"",llGetOwner(),"");
}
listen(integer chan, string name, key id, string msg)
{
if(llSubStringIndex(llToLower(msg),"kiss") != -1)
llSensor(llDeleteSubString(msg,0,4),"",AGENT,20,TWO_PI);
}
sensor(integer total_number)
{
llRequestPermissions(llDetectedKey(0),PERMISSION_TRIGGER_ANIMATION);
llMessageLinked(LINK_SET,0,"hugged","");
}
run_timer_permissions(integer perm)
{
// Uncomment if this is a looping animation
// llSetTimerEvent(5.0);
if(perm)
llStartAnimation(animation);
}
timer()
{
llSetTimerEvent(0.0);
llStopAnimation(animation);
}
}


And script numero dos:
CODE
string animation = "stand"; // Animation name here!

default
{
link_message(integer sender, integer num, string str, key id)
{
if(str == "hugged")
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
}
run_timer_permissions(integer perm)
{
// Uncomment if this is a looping animation
// llSetTimerEvent(5.0);
if(perm)
llStartAnimation(animation);
}
timer()
{
llSetTimerEvent(0.0);
llStopAnimation(animation);
}
}

Hmph. :D

Note that this is still untested. Let me know if it has any further problems.
_____________________
---
Storma Amarula
Registered User
Join date: 8 Mar 2005
Posts: 87
04-07-2005 13:16
Hi Jeffery,


Thanks a lot, hack or not the script works great. Just two more usage question if you have time.

1) If I have a looping animation and I, or the other Avatar, wanted to type stop the animation with a command such as "/1 stop" how would I do that?

2) If I wanted to have more than one animation available such as "/1 kiss (AVNAME)", "/1 hug (AVNAME)" ..etc how should that be set-up?

Thanks for your help.
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-07-2005 17:45
No problem.

From: Storma Amarula
1) If I have a looping animation and I, or the other Avatar, wanted to type stop the animation with a command such as "/1 stop" how would I do that?

CODE
     listen(integer chan, string name, key id, string msg)
{
if(llSubStringIndex(llToLower(msg),"stop") != -1)
llStopAnimation(animation);
}



From: Storma Amarula
2) If I wanted to have more than one animation available such as "/1 kiss (AVNAME)", "/1 hug (AVNAME)" ..etc how should that be set-up?

CODE
     listen(integer chan, string name, key id, string msg)
{
if(llSubStringIndex(llToLower(msg),"hug") != -1)
llSensor(llDeleteSubString(msg,0,4),"",AGENT,20,TWO_PI);
}


For the second one, however, you'll need to pass to the sensor what animation you're using. You can do that by simply storing the message as a global variable and going from there. :)
_____________________
---