Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Owner says something >> something happens

a lost user
Join date: ?
Posts: ?
08-15-2005 15:01
I'm trying to make it so when I get in my plane I say Engine On and the prop begins to spin.

I already have the right animation - I just don't even remotely know what script I would need to have to make the animation begin when I say something.

Any help is appreciated...

I've looked all over the Wiki but it just explains commands.

How am I supposed to know where all the random {

)

; things go?
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
08-15-2005 15:05
Jeffrey made this fabulous intro to LSL (the scripting language of SL). It will walk you through the basic concepts of scripting, including where you uth the squigglies. :D
_____________________
Angus Kuhr
Dwarf with a Hammer
Join date: 17 Jul 2005
Posts: 43
08-16-2005 03:08
There are several ways to do that, but the best one is to use States, in my experience.

From: someone
default()

{

state_entry()

{

key kOwner = llGetOwner(); // This sets the key for the listen.
llListen(0, "", kOwner, "";); // This sets it to listen to channel 0 and only to the owner.

}

listen(integer channel, string name, key id, string message)

{

if(message == "Engine On";)

{

state spinning;

}

}

state spinning

{

state_entry()

{

llStartAnimation("ANIMATION NAME HERE";);
llListen(0, "", kOwner, "";);

}

listen(integer channel, string name, key id, string message)

{

if(message == "Engine Off";)

{

state not_spinning;

}

}

}

state not_spinning

{

state_entry()

{

llStopAnimation("ANIMATION NAME HERE";);
llListen(0, "", kOwner, "";);

}

listen(integer channel, string name, key id, string message)

{

if(message == "Engine Off";)

{

state spinning;

}

}

}



That is absolute barest way I would do that. You'll need to do a bit of tinkering to get it to do precisely what you want and when you want it. And, if you plan on giving the object away or selling it, you'll have to have a periodic check on kOwner. That way, it'll adjust to whoever might own it. You can also add sounds and stuff if you like, of course.

Anyhoo...in situations where you want it to be doing ONE thing or the OTHER thing, I've found that it's best to use states. That way, the script is NOT confused as to where it is and what it should be doing.