Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

New scripter that doesn't know where to look

Demise Slichter
Registered User
Join date: 16 Jun 2006
Posts: 2
05-30-2008 19:03
Hi every one. first off, i'm new to scripting, i've been good at modifying scripts in the past so i thought I'de give it a shot but everytime I go on the wiki to fid a code section I want I have no ide what to look for, every time it comes up empty handed so i thought I'de ask here.

I have a object rotation script for a wet of wings, it moves 25 degrees and then to -25. I "flaps" a few times then stops. I'm goign to place the movement scrit here and I really hope some one can either instrusct me cause i feel liek an idiot, or point me in the right direction.

Thing's I'm trying to add
a chat command to start and stop it
make it "flap or wag" indefinatly untill the owner tells it to stop
a link from each wing to the root prim (hidden inside of the body) to keep them synced



// Zi's wag V1.0
//
// Description: makes your tail wag softly
// Installation: edit your tail, open "Content" and Drag & Drop it into the contents folder
// Licence: copy freely, charge nothing

// holds the tail position before starting the script
vector originalPosition;

// do the actual wagging
doWag()
{
integer amplitude=25; // maximum wagging width in degrees
integer numOfWags=4; // how many times to be wagged
float steps=15; // how many steps per wag, higher is slower
float moveBy=0; // current wagging position

// start wagging, count the steps
integer num=0;
while(num<;(steps*numOfWags))
{
// calculate new tail position
moveBy=llSin(num/(steps/2)*PI)*amplitude;
// rotate tail
llSetRot(llEuler2Rot(DEG_TO_RAD*(originalPosition+<0,moveBy,0>;)));
// next step
num++;
}
// set back to original position
llSetRot(llEuler2Rot(DEG_TO_RAD*(originalPosition)));
}

// program starts here
default
{
state_entry()
{
// remember tail position when not wagging
originalPosition=(RAD_TO_DEG*llRot2Euler(llGetLocalRot()));
// start first wagging almost immediately
llSetTimerEvent(1);
}

// every ten seconds
timer()
{
// wag the tail
doWag();
// restart timer, next ten seconds
llSetTimerEvent(10+llFrand(10));
}
}




any help will be GREATLY appriciated! Ty for your time
Galena Qi
Registered User
Join date: 9 Sep 2006
Posts: 249
05-30-2008 21:30
That's a lot of changes to this script (which is probably why people aren't jumping in to revise it), but here are a few pointers that may help you find the right code on the wiki.

To respond to a chat command: llListen (use an if/else in the listen event to either stop or start the wag)

To communicate from the parent prim to linked prims: llMessageLinked

An easier approach if you aren't getting anywhere with this script would be to animate the wings using the free prim animation program Puppeteer. You can set the animation to start and stop with a chat command.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
05-30-2008 22:00
Just a little hint that really helped me. Early on, when learning scripting, don't approach it from the angle of "I need to code this", and try to find the functions that will make it happen, rather, sift through function pages and just read the name of each function. When you see an interesting function, follow that link, read about that function, paste the example (if there is one) into a script in world, and test it out. Try and get the hang of just that one function. Then, go back to the wiki, and pick out another one and do the same. Before long, you'll have a small handful of functions that you have a pretty good take on, you'll even be able to combine a few of them into a whole new script that uses this tiny handful of functions that you have a good grip on. Then, after a while, can't say exactly when, you'll get to the point where you'll be able to tackle a scripting job from the front end rather than the back end. Also, it's a good idea to read the section on variables and get a good understanding of each variable type, and casting between different types. Lastly, read the section on events as well. Nothing happens unless an event is triggered, so it's a good idea to browse through the events and read up on those so you know what events to put your code into. So, start on the section on variables, read through that, then read about the events, then start work on the functions. You will probably not totally understand everything the first time you read it, but dont worry, finish reading through it anyways and move on, and later, when you're coding, you can refer back to it, and it will make more sense the 2nd (or 3rd, or 20th!) time around.
Dnali Anabuki
Still Crazy
Join date: 17 Oct 2006
Posts: 1,633
05-31-2008 08:11
Wonderful Johan, thanks. Great way to untangle the mass of info.
Demise Slichter
Registered User
Join date: 16 Jun 2006
Posts: 2
Ty!
05-31-2008 12:57
Thank you everyone, i'm headed to check out thoes codes on wiki now!