Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Simple Linked Objects Animation Script

Nightspy Rebus
Scripter Bum
Join date: 17 Jun 2004
Posts: 45
06-16-2005 16:59
I have written a simple animation script that takes out the guessing out of animated vehicles doors and animated objects , you can do some pretty complex object animations with this.

the script is activated by addressing the object name
example: door capture // will make the object named door go into active capture mode
, to set a new frame say , door set , to play the frames go into play mode , say door play , and then call the frame requested , door frame 1 for ex.


CODE


//Linked animation Script by nightspy rebus.

//notice scale doesn't work on objects an avie sits on

string control_part;
list pos;
list rot;
list scale;

vector org;
vector tpos;

animate(string x)
{
integer i=(integer)x;
vector scalet=llList2Vector(scale,i);
vector post=llList2Vector(pos,i);
rotation rott=llList2Rot(rot,i);
llSetScale(scalet);
llSetPos(post);
llSetLocalRot(rott);

}

default
{
state_entry()
{
llListen(0,"","","");
llListen(1221,"","","");
llOwnerSay("play mode: "+(string)
llGetListLength(pos)+" frames captured");
}


link_message(integer sender_num, integer num, string message, key id)
{
control_part=llToLower(llGetObjectName());
list cmd=llParseString2List(llToLower(message),[" "],[""]);
if(llList2String(cmd,0)==control_part)
{
if(llList2String(cmd,1)=="frame")
{
if(llList2Integer(cmd,1)>(llGetListLength(pos)+-1));
else
animate(llList2String(cmd,2));
}
if(llList2String(cmd,1)=="capture")
{
state capture;
}
if(llList2String(cmd,1)=="frames")
{
llOwnerSay((string)llGetListLength(pos)+" frames captured");
}

}
}
}

state capture
{
state_entry()
{
pos=[];
rot=[];
scale=[];
llListen(0,"","","");
llOwnerSay("capture mode");
}


listen(integer channel,string name,key id,string message)
{
if(id==llGetOwner())
{
control_part=llToLower(llGetObjectName());
list cmd=llParseString2List(llToLower(message),[" "],[""]);

if(llList2String(cmd,0)==control_part)
{
if(llList2String(cmd,1)=="play")
{
state default;
}
if(llList2String(cmd,1)=="frames")
{
llOwnerSay((string)llGetListLength(pos)+" frames captured");
}
if(llList2String(cmd,1)=="set")
{
{
pos+=llGetLocalPos();
rot+=llGetLocalRot();
scale+=llGetScale();
}

}
}

}
}
}



And an exmaple controller scripts
CODE

default
{
state_entry()
{

llListen( 0, "", NULL_KEY, "" );

}

listen( integer channel, string name, key id, string message )
{
llMessageLinked(LINK_SET, 0, message, "");
}
}


CODE

integer door=FALSE;
integer i;
default
{
state_entry()
{
llListen(0,"","","");
}

listen(integer channel,string name,key id,string msg)
{
if(id==llGetOwner())
{
if(msg=="open door")
{
if(door==FALSE)
{
for(i=0;i<5;i++) //set the number of frames to play for door object aniamtion
{
llSay(1221,"door frame "+(string)i);
llSleep(1);
}
door=TRUE;
}
}

if(msg=="close door")
{
if(door==TRUE)
{
llSay(1221,"door frame 0");
llSleep(1);
}
door=FALSE;
}
}
}
}

Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
06-18-2005 09:55
/15/fa/50560/1.html
_____________________
i've got nothing. ;)
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
08-01-2005 01:48
This is very cool! I been playing with it and have gotten a flower with 9 peddels
to unfold i made some changes to script so you use a hot key to record each frame
so i can stay in edit indivule mode.
one question is there a way to save the lists (pos,rot,scale) so they wont be lost if the
script gets reset?
mabe save to notecard and load them back?
Thanks for the script ive been having fun with it :)
-LW
Tina Gascoigne
Registered User
Join date: 4 Apr 2005
Posts: 35
nightspy nightpsy nightspy
08-16-2005 07:02
you know i can do much better than that!! msg me at tinagascoign@yahoo etc hmmm
a lost user
Join date: ?
Posts: ?
08-16-2005 07:25
From: Lightwave Valkyrie
This is very cool! I been playing with it and have gotten a flower with 9 peddels
to unfold i made some changes to script so you use a hot key to record each frame
so i can stay in edit indivule mode.
one question is there a way to save the lists (pos,rot,scale) so they wont be lost if the
script gets reset?
mabe save to notecard and load them back?
Thanks for the script ive been having fun with it :)
-LW


You can't create notecards or write to them in SL, so that option is out. You could send the lists to another object using either llSay(), llShout() or llEmail(). Or you could simply output the lists to chat and cut and paste them into a notecard manually, then put that notecard into the object to be read on_rez. There's always a way.. but sometimes it's a little clumsy. Such as trying to get an object's name when it is in another sim. The only way to do that is to send it an email and get it to email its name back again... clumsy.
Blain Candour
Registered User
Join date: 17 Jun 2005
Posts: 83
08-16-2005 07:25
Better than what? Her request or the script? That was an awfully vague post but I'd be interested in seeing any animation scripting you have.
_____________________
DISCLAIMER: Blain Candour is a total and eternal n00b and everything he tells you should be taken with a huge pile of salt. Especially when he refers to himself in third person!