Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Scripts for Sounds: Help Needed.

Keaira Skytower
Registered User
Join date: 23 May 2008
Posts: 9
08-28-2008 10:28
Hello. I need assistance with adding sound to a script that already exists.

First, I had a quick question on sound... I have seen some scripts that refer to the UUID's and some that refer to inventory content of the object. Which style is easier for script newbs? If it's inventory content code, I will just be able to drag and drop a sound from my inventory into the inventory of the object, and it will just pull from what is in the object inventory - right?

Second, I want to make a silly little thing to follow me, but I'd like it to randomly play one of three sounds. Not by touch, but just random, maybe on a timer or something. There is this pet follow script here:

/54/fc/29116/1.html

How do I add in code to randomly play sound? Can I just cut and paste code anywhere in there or does it need to go some place specifically?

I've tried cutting one script and adding it to another and it never seems to work. So, I'm wondering, what the transition needs to be. I am not a scriptor so this may not make sense. I'm thinking I may need to take the headers out, but not sure where to stop deleting. Anyway, if you guys have any tips about mixing components of one script with another, I'd very much appreciate it!

Thank you!
Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
08-28-2008 21:24
From: Keaira Skytower
Hello. I need assistance with adding sound to a script that already exists.

First, I had a quick question on sound... I have seen some scripts that refer to the UUID's and some that refer to inventory content of the object. Which style is easier for script newbs? If it's inventory content code, I will just be able to drag and drop a sound from my inventory into the inventory of the object, and it will just pull from what is in the object inventory - right?


Hi, Keaira!

Afaik, it's largely a matter of personal choice (and whether you want to 'hide' a sound within a locked script, when reselling).

Some widely-used sounds, such as door open/close noises, tend to be called by their UUID simply because those are more readily available than the sound files.

From: Keaira Skytower
Can I just cut and paste code anywhere in there or does it need to go some place specifically?

I've tried cutting one script and adding it to another and it never seems to work. So, I'm wondering, what the transition needs to be. I am not a scriptor so this may not make sense. I'm thinking I may need to take the headers out, but not sure where to stop deleting. Anyway, if you guys have any tips about mixing components of one script with another, I'd very much appreciate it!


Like all programs, LSL scripts have to follow a certain structure. Mountains of advice are available, though I'm afraid they tend to be scattered around ... There is a book on LSL.

The default "absolute beginners" tutorial is here: read it, it explains quite well. http://wiki.secondlife.com/wiki/Help:Getting_started_with_LSL

For writing your scripts, Alphons Jano's LSL Editor is a godsend. Download it from http://www.lsleditor.org/.

From: Keaira Skytower
Second, I want to make a silly little thing to follow me, but I'd like it to randomly play one of three sounds. Not by touch, but just random, maybe on a timer or something. There is this pet follow script here:

/54/fc/29116/1.html

How do I add in code to randomly play sound?


I haven't tested this. Hope it works!
Please see my comments.

CODE


////////////////////////////////////////////////////////////////
// Open Basic Follower/Facing Script, by Logan Bauer. //
////////////////////////////////////////////////////////////////
// OFFSET is the position of your pet in relation to it's owner's position.
// For example, in the default setting below, "vector offset =<-1,0,1>;"
// I.E. (x,y,z), the -1 puts it 1m back behind owner, the 0 means don't have
// it stay left or right, and 1 means have it stay 1m above it's owner.
// So, if you wanted the script to make it follow directly in front of you,
// and to the left, then you would change it to "vector offset =<1,1,0>;"

vector offset =<-1,0,1>;

// list the exact names of sounds in your pet's inventory (or the UUIDs) here
list mySounds = ["first sound", "second sound", "third sound", "fourth sound"];

// startup is a function - like a mini-script. It is called later on by 'startup()'
startup()
{
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_Z,TRUE);
llSetStatus(STATUS_PHYSICS, TRUE);
key id = llGetOwner();
llSensorRemove();
llSensorRepeat("",llGetOwner(),AGENT,200,2*PI,.5);
}

// here's another function to randomise your sounds
ransound()
{
llTriggerSound( llList2String( llListRandomize( mySounds, 1 ), 0 ), 1.0);
}

// This is the beginning of the actual script, they all start like this
default
{

state_entry()
{

startup();

}

on_rez(integer start_param)
{
startup();
}

sensor(integer total_number)
{
vector pos = llDetectedPos(0);
llMoveToTarget(pos+offset*llDetectedRot(0),.3);
llLookAt(pos, .1 , 1);
ransound();
}
}



To understand the random part, take a look at llListRandomize here: http://wiki.secondlife.com/wiki/LlListRandomize[/url
and Void's reply to an interesting forum post, here:
[url=/54/ed/246734/1.html#post1907884]/54/ed/246734/1.html#post1907884[/url]

Cherry.
_____________________
=================
My stuff on XSt:-
http://tinyurl.com/383mgh
Keaira Skytower
Registered User
Join date: 23 May 2008
Posts: 9
08-29-2008 08:35
Thank you, Cherry! I'll play with that script tonight and see. I've not seen the LSL editor yet. And I can't believe I didn't find it. It looks like it's going to be sooooo helpful!

I was looking at some of the tutorials and I'm afraid they were still over my head :) hehehehhe, but I'm going to go back and try again. It's just harder to wrap my mind around the structure I think and knowing how to space things and when to use the brackets versus the quotes and parenthesis :)


Completely off topic, but somehow that cheesy song, "I love you period, do you love me question mark, I want to hold you in parenthesis...." just plays in my head when I try and work on scripts and completely distracts me.
Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
08-29-2008 12:36
From: Keaira Skytower
that cheesy song, "I love you period, do you love me question mark, I want to hold you in parenthesis...." just plays in my head when I try and work on scripts and completely distracts me.


:D Brilliant!
......... damn, now I've got it!

Cx
_____________________
=================
My stuff on XSt:-
http://tinyurl.com/383mgh