Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

creating a script that rezzes or animates

ChaiBoy Rang
Registered User
Join date: 9 Mar 2007
Posts: 29
06-23-2008 10:30
Hi i've seen where there are objects (such as some of the pregnancy bellies) that allow you ot rez an object into your hand. I would like some advice on making an object that can rez an object or plays an animation by voice command.

I assume i have to make a channel listener.
then a controller that can look for the animation or object and depending on which it fnds play or wear item.

Does this sound about right? is there any script out there that might get me started?
Cory Fimicoloud
Registered User
Join date: 23 May 2007
Posts: 5
06-23-2008 10:48
You would use the llRezObject function to rez a object. As for playing an animation by voice command, you would use a speech gesture. Some example ones are in your inventory under Library -> Gestures -> Speech Gestures.
ChaiBoy Rang
Registered User
Join date: 9 Mar 2007
Posts: 29
06-23-2008 11:14
i am filling an object with animations. What i want to do is be able to say the name of an animation such as say jump_high or /123 jump_high and the script look through the objects inventory for Jump_high. That kind of thing.

I guess what i need to know first is how do i fill a list with the contents of a objct.
ChaiBoy Rang
Registered User
Join date: 9 Mar 2007
Posts: 29
06-23-2008 11:40
I found this script which seems to do something like what i want. Looking at changing the animation list.

////////////////////////////////////////////
// Animation Script
//
// Written by Xylor Baysklef
////////////////////////////////////////////

/////////////// CONSTANTS ///////////////////
list ANIMATIONS = [ "aim_L_bow", "aim_R_bazooka", "aim_R_handgun", "aim_R_rifle", "angry_fingerwag",
"angry_tantrum", "away", "backflip", "blowkiss", "bow", "brush", "clap",
"courtbow", "crouch", "crouchwalk", "dance1", "dance2", "dance3", "dance4", "dance5", "dance6", "dance7", "dance8",
"dead", "drink", "express_afraid", "express_anger", "express_bored",
"express_cry", "express_embarrased", "express_laugh", "express_repulsed",
"express_sad", "express_shrug", "express_surprise", "express_wink",
"express_worry", "falldown", "female_walk", "fist_pump", "fly", "flyslow",
"hello", "hold_R_bazooka", "hold_R_handgun", "hold_R_rifle",
"hold_throw_R", "hover", "hover_down", "hover_up", "impatient",
"jump", "jumpforjoy", "kick_roundhouse_R", "kissmybutt", "land", "laugh_short", "motorcycle_sit", "musclebeach", "no_head", "no_unhappy",
"nyanya", "peace", "point_me", "point_you" ];

list ANIMATIONS2 = [ "prejump", "punch_L", "punch_onetwo", "punch_R",
"RPS_countdown", "RPS_paper", "RPS_rock",
"RPS_scissors", "run", "salute", "shoot_L_bow", "shout", "sit", "sit_ground", "sit_to_stand",
"sleep", "smoke_idle", "smoke_inhale", "smoke_throw_down",
"snapshot", "soft_land", "stand", "standup", "stand_1", "stand_2",
"stand_3", "stand_4", "stretch", "stride", "surf", "sword_strike_R",
"talk", "throw_R", "tryon_shirt", "turnback_180", "turnleft", "turnright",
"turn_180", "type", "walk", "whisper", "whistle", "wink_hollywood",
"yes_happy", "yes_head", "yoga_float" ];
///////////// END CONSTANTS /////////////////

///////////// GLOBAL VARIABLES ///////////////
//integer gToggle = 0;
integer gAnimNumber;
integer gTotalAnims;

string gAnimName = "type";
/////////// END GLOBAL VARIABLES /////////////

default {
state_entry() {
//llSay(0, "Init...";);
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);

ANIMATIONS += ANIMATIONS2;
ANIMATIONS2 = [];

gTotalAnims = llGetListLength(ANIMATIONS);
gAnimNumber = -1;
llListen(123, "", llGetOwner(), "";);
}

on_rez(integer param) {
//llGiveInventory(llGetOwner(), "Animation Names";);
llResetScript();
}

listen(integer channel, string name, key id, string mesg) {
string preamble = llGetSubString(mesg, 0, 3);
if (preamble != "anim" && preamble != "stop";)
return;

integer perm = llGetPermissions();

if ( !(perm & PERMISSION_TRIGGER_ANIMATION)) {
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
return;
}

list parsed = llParseString2List(mesg, [ " " ], []);
//llSay(0, (string)parsed);

string anim = llList2String(parsed, 1);

if (preamble == "stop";) {
//llSay(0, "Stopping: " + llGetAnimation(llGetOwner()));
//llStopAnimation(llGetAnimation(llGetOwner()));
if (anim == "";)
anim = gAnimName;

if (anim == "all";) {
integer i;
llSay(0, "Stopping all animations... please wait.";);
for (i=0; i<gTotalAnims; i++)
llStopAnimation(llList2String(ANIMATIONS, i));

llSay(0, "Done.";);

return;
}

//llSay(0, "Stopping: " + anim);
llStopAnimation(anim);
return;
}

gAnimName = anim;
//llSay(0, "Animation: " + gAnimName);
llStartAnimation(gAnimName);
}

run_time_permissions(integer perm) {
//llStopAnimation(gAnimName);
//gToggle = 0;
}

attach(key id) {
integer perm = llGetPermissions();

if (id != NULL_KEY) {

if (! (perm & PERMISSION_TRIGGER_ANIMATION)) {
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}
}
else {

if (perm & PERMISSION_TRIGGER_ANIMATION) {
llStopAnimation(gAnimName);
}
}
}

touch_start(integer total_number) {
if (llDetectedKey(0) != llGetOwner())
return;

integer perm = llGetPermissions();

if (perm & PERMISSION_TRIGGER_ANIMATION) {
if (gAnimNumber != -1) {
llStopAnimation( llList2String(ANIMATIONS, gAnimNumber) );
}


gAnimNumber++;
if (gAnimNumber == gTotalAnims)
gAnimNumber = 0;

gAnimName = llList2String(ANIMATIONS, gAnimNumber);

llStartAnimation( gAnimName );
llSay(0, "Animation: " + gAnimName);
}
else {
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}
}
}
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
06-23-2008 23:24
lists eat up a lot of memory.

In your case it is most likely better to approach this in a different way.

If you just want to animate your avatar then you can just search through the inventory items of the prim in question that are animations and look for the one you want when you need to do it. And then play it. And also remember the last played animation so you can properly stop it after starting the next one.

Not using lists will not limit you to how much memory your script has available to store the lists but lets you use as many animations as you can cram into the objects inventory. Searching through the inventory will likely be even faster than having to go through lists.